Suppose we have two normal vectors $v, u \in \mathbb{R}^n, \|u\|_2=1, \|v\|_2=1$. We would like to find a rotation matrix $R\in\mathbb{R}^{n \times n}$ that satisfies $R u = v$. This clearly does not uniquely determine matrix $R$ because there are only $n$ equations while there are $n(n-1)/2$ degrees of freedom for $R$. However we can make it unique by forcing it to only rotate vectors in the $Span\{u,v\}$. In other words: $$\forall w \in Span\{u,v\}^\perp : R w = w$$ Intuitively, it only rotates vectors in the $Span\{u,v\}$ plane while leaving every other direction untouched. In this sense, the rotation matrix is minimal.
In the very simple case that $Span\{u,v\} = Span\{e_i,e_j\}$, i.e., the linear space spanned by $u,v$ is the same as the one spanned by $e_i, e_j$ we can compute $R$ as follows: $R = I_n - M$, in which $M\in \mathbb{R}^{n\times n}$ is only zeros except for its $i$-th and $j$-th rows and columns: $$M_{i, j\times i, j} = \begin{bmatrix} 1-\cos \theta & \sin \theta\\ -\sin\theta & 1-\cos\theta \\ \end{bmatrix}$$ in which $\theta = \cos^{-1} \langle u, v \rangle$
Is there a way to compute the rotation matrix for general normal vectors $u, v$?
Let $v_1,v_2 \in\mathbb{R}^n$ be linearly independent normal vectors, i.e. $\|v_1\|=\|v_2\|=1$ and $\operatorname{dim}\operatorname{Span}(v_1,v_2)=2$.
Let $\{r_3, r_4,\dots, r_n\}$ be an orthonormal basis for the orthogonal complement $\operatorname{Span}(v_1,v_2)^{\perp}$ of the plane spanned by $v_1$ and $v_2$.
First we find an orthonormal basis for $\operatorname{Span}(v_1,v_2)$, let it be $\{w_1,w_2 \}$. One can simply use Gram–Schmidt process to obtain this basis as $$ w_1 = v_1,\quad w_2 = \frac{\Big(v_2-(v_2^{\rm T}w_1)w_1\Big)}{\|v_2-(v_2^{\rm T}w_1)w_1\|} \;. $$
Then the desired minimal rotation matrix $R$ can be found as
$$ R = \underbrace{\begin{bmatrix} \rule[-1ex]{0.5pt}{6.6ex} & \rule[-1ex]{0.5pt}{6.5ex} & \rule[-1ex]{0.5pt}{6.6ex} & & \rule[-1ex]{0.5pt}{6.6ex} \\ w_1 & w_2 & r_3 & \dots & r_n \\ \rule[-1ex]{0.5pt}{6.6ex} & \rule[-1ex]{0.5pt}{6.6ex} & \rule[-1ex]{0.5pt}{6.5ex} & & \rule[-1ex]{0.5pt}{6.6ex}\end{bmatrix}}_{\Pi} \underbrace{\begin{bmatrix} \cos(\theta) & -\sin(\theta) & & \\ \sin(\theta) & \phantom{-}\cos(\theta) & & \\ & & 1 & \\ & & & \ddots & \\ & & & & 1\end{bmatrix}}_{S} \underbrace{\begin{bmatrix} \rule[-1ex]{0.5pt}{6.6ex} & \rule[-1ex]{0.5pt}{6.5ex} & \rule[-1ex]{0.5pt}{6.6ex} & & \rule[-1ex]{0.5pt}{6.6ex} \\ w_1 & w_2 & r_3 & \dots & r_n \\ \rule[-1ex]{0.5pt}{6.6ex} & \rule[-1ex]{0.5pt}{6.6ex} & \rule[-1ex]{0.5pt}{6.5ex} & & \rule[-1ex]{0.5pt}{6.6ex}\end{bmatrix}^{\rm T}}_{\Pi^{\rm T}}, $$
where $\theta=\arccos(v_1^{\rm T}v_2)$ if $\{w_1,w_2\}$ were obtatined with Gram-Schmidt process, but in general $\theta=\pm\arccos(v_1^{\rm T}v_2)$. The sign is "$+$" if the orientation of $\{w_1,w_2\}$ is the same as the orientation of $\{v_1,v_2\}$, and the sign is "$-$" otherwise. Note that Gram-Schmidt process preserves orientation and gives us a "$+$".
Note that $\Pi \in O(n)$ and $S \in SO(n)$ and thus $$R^{}=\Pi^{} S^{} \Pi^{\rm T} = \Pi^{} S^{} \Pi^{-1} \in S^{}O^{}(n)$$ is a rotation.
Let $\{e_i\}_{i=1}^{n}$ denote a standard basis in $\mathbb{R}^n$. One can see that
$$ R^{}r_i = \Pi^{} S^{} \Pi^{\rm T} r_i = \Pi^{} S^{} e_i = \Pi^{} e_i = r_i , $$
which means that $R$ acts as an identity map on $\operatorname{Span}(v_1,v_2)^{\perp}$.
Both $v_1$, $v_2$ are sent by $\Pi ^{\rm T}$ to $\operatorname{Span}(e_1,e_2)$, then rotated by $S$ through an angle $\theta$ and then sent back by $\Pi$. The fact that $\Pi$ is an orthogonal matrix guarantees that the angle between $\Pi ^{\rm T}v_1$ and $\Pi ^{\rm T}v_2$ is the same as the angle between $v_1$ and $v_2$ and we have
$$ S^{}\Pi ^{\rm T}v_1=\Pi ^{\rm T}v_2 $$
$$ v_2=\Pi^{}S^{}\Pi ^{\rm T}v_1 $$
$$ v_2=Rv_1 $$