Definition: Let X be an inner product space over ##\mathbb R##. For each ##x,y\in X-\{0\}##, define the angle between ##x## and ##y##, denoted by ##\theta(x,y)##, by
$$\cos\theta(x,y)=\frac{\langle x,y\rangle}{\|x\|\|y\|}.$$
Note that the Cauchy-Schwartz inequality ensures that the right-hand side is in the interval [-1,1].
Theorem: Let X be an inner product space over ##\mathbb R##. If ##R:X\to X## is surjective onto ##X## and preserves distances and angles, then ##R## is an orthogonal linear transformation (i.e. a linear transformation that preserves norms).
Proof: We will prove that ##R## preserves norms. Let ##x\in X##. Since ##R## preserves distances, we have ##\|Rx\|=\|R(x-0)\|=\|x-0\|=\|x\|##. Since ##x## is an arbitrary element of ##X##, this means that ##R## preserves norms.
We will prove that ##R## preserves inner products. Let ##x,y\in X-\{0\}##. Since ##R## preserves angles and norms, we have
$$\frac{\langle x,y\rangle}{\|x\|\|y\|}=\cos\theta(x,y)=\cos\theta(Rx,Ry)=\frac{\langle Rx,Ry\rangle}{\|Rx\|\|Ry\|} =\frac{\langle Rx,Ry\rangle}{\|x\|\|y\|}.$$ This implies that ##\langle x,y\rangle=\langle Rx,Ry\rangle##. Since ##x,y## are arbitrary elements of ##X##, this means that ##R## preserves inner products.
We will prove that ##R## is linear. Let ##a,b\in\mathbb R##. Let ##x,y,z\in X##. Let ##w\in X## be such that ##Rw=z##.
\begin{align*}
&\langle z,R(ax+by)\rangle =\langle Rw,R(ax+by)\rangle =\langle w,ax+by\rangle =a\langle w,x\rangle+b\langle w,y\rangle =a\langle Rw,Rx\rangle+b\langle Rw,Ry\rangle\\
& =\langle z,aRx+bRy\rangle.
\end{align*} Since ##z## is an arbitrary element of ##X##, this implies that ##R(ax+by)=aRx+bRy##. Since ##a,b## are arbitrary real numbers and ##x,y## are arbitrary elements of ##X##, this means that ##R## is linear.
Comment: You may still be wondering why a norm-preserving linear transformation would be orthogonal in the sense ##R^TR=I##. The standard inner product on ##\mathbb R^3## is given by ##\langle x,y\rangle =x^Ty##. So for all ##x\in\mathbb R^3##, we have
$$x^Tx=\langle x,x\rangle =\|x\|^2=\|Rx\|^2=\langle Rx,Rx\rangle =(Rx)^T(Rx)=x^TR^TRx.$$ This implies that ##R^TR=I##. (The idea is to make clever choices of x that I don't have time to explain right now).