Given two lines in ${\mathbb{R}^3}$ by:
$$\begin{gathered}
X = P + r \cdot U \hfill \\
Y = Q + s \cdot V \hfill \\
\end{gathered} $$
Here we use $P,Q \in {\mathbb{R}^3}$ as "starting" points and $U,V \in {\mathbb{R}^3}$ as directions.
We take the blue line for our first paramtrization and the orange one for second. Both lines have edges of the cube in common, but different ones.
Blue line has bottom face and orange line has top face from the cube in common.
So these planes are parallel to each other.
Because lines have different directions, they aren't parallel.
We want to calculate the shortest distance of the two given lines.
The distance of two arbitrary points (here the red segment) seems not
to have shortest lenght. The green segment looks much better.
But what can we say about the green segment? The cube help's us to find the
answer quickly: The green segment is that edge of the cube, that joines
the blue line with the orange one and is perpendicular with both lines.
This makes the green segment very special. But why?
There is one very good reason. From the given directions $U,V \in {\mathbb{R}^3}$ we can build the vector or cross product $U \times V$
and we know the dots from $U \times V$ with $U$ and from $U \times V$
with $V$ are zero. That is $U \times V \bot U$ and $U \times V \bot V$.
This is important for our calculation. Let's go:
The red segment starts in point $X$ from the blue line and ends in point
$Y$ from the orange line. We write for direction vector from $X$ towards
$Y$:
$$\begin{gathered}
\overrightarrow {XY} = Y - X \hfill \\
\overrightarrow {XY} = s \cdot V - r \cdot U + \overrightarrow {PQ} \hfill \\
\end{gathered} $$
And of course, here $\overrightarrow {PQ} = Q - P$ is the vector which starts
in $P$ and ends in $Q$.
For the green segment we use point $A$ from the blue line as starting point and
$B$ from the orange line as ending point. And we write $\overrightarrow {AB} = B - A$ as usual for direction.
But, do you remember? $\overrightarrow {AB} $ has same direction as $U \times V$! We can say this more precise:
$$\overrightarrow {AB} = t \cdot U \times V$$
for a number $t \in \mathbb{R}$.
And now, we want the direction $\overrightarrow {XY} $ to be $\overrightarrow {AB} $. Well that is
$$\begin{gathered}
\overrightarrow {AB} = \overrightarrow {XY} \hfill \\
\hfill \\
t \cdot U \times V = s \cdot V - r \cdot U + \overrightarrow {PQ} \hfill \\
\end{gathered}$$
Why are we doing this? We want to find that number $t \in \mathbb{R}$.
And in less than a second, we are done. Applying the dot with $U \times V$
in last equation gives instantly:
$$\begin{gathered}
t \cdot \left( {U \times V \cdot U \times V} \right) = s \cdot \left( {V \cdot U \times V} \right) - r \cdot \left( {U \cdot U \times V} \right) + \overrightarrow {PQ} \cdot U \times V \hfill \\
\hfill \\
t \cdot {\left\| {U \times V} \right\|^2} = \overrightarrow {PQ} \cdot U \times V \hfill \\
\end{gathered} $$
because $U \cdot U \times V = V \cdot U \times V = 0$. At this point we can't calculate on without an assumption. To eliminate for $t$ we have to divide with
${\left\| {U \times V} \right\|^2}$. If the directions $U,V \in {\mathbb{R}^3}$ for our lines are linear independent, then $U \times V \ne \vec 0$ and has a length different from zero. So we get for $t$:
$$t = \frac{{\overrightarrow {PQ} \cdot U \times V}}{{{{\left\| {U \times V} \right\|}^2}}}$$
And also we get the shape for
$$\overrightarrow {AB} = \frac{{\overrightarrow {PQ} \cdot U \times V}}{{{{\left\| {U \times V} \right\|}^2}}} \cdot U \times V$$
What about the length for this $\overrightarrow {AB} $? Here it is:
$$\begin{gathered}
\overrightarrow {AB} \cdot \overrightarrow {AB} = {\left\| {\overrightarrow {AB} } \right\|^2} = \frac{{\overrightarrow {PQ} \cdot U \times V}}{{{{\left\| {U \times V} \right\|}^2}}} \cdot \frac{{\overrightarrow {PQ} \cdot U \times V}}{{{{\left\| {U \times V} \right\|}^2}}} \cdot {\left\| {U \times V} \right\|^2} \hfill \\
\hfill \\
{\left\| {\overrightarrow {AB} } \right\|^2} = \frac{{{{\left( {\overrightarrow {PQ} \cdot U \times V} \right)}^2}}}{{{{\left\| {U \times V} \right\|}^2}}} \hfill \\
\hfill \\
\left\| {\overrightarrow {AB} } \right\| = \frac{{\left| {\overrightarrow {PQ} \cdot U \times V} \right|}}{{\left\| {U \times V} \right\|}} \hfill \\
\end{gathered} $$
And if we re-write: $\overrightarrow {PQ} = Q - P$
$$\left\| {\overrightarrow {AB} } \right\| = \frac{{\left| {(Q - P) \cdot U \times V} \right|}}{{\left\| {U \times V} \right\|}}$$
So:
Given two lines in $\phi ,\psi \subset {\mathbb{R}^3}$ with points $P,Q \in {\mathbb{R}^3}$ and directions $U,V \in {\mathbb{R}^3}$, that are of shape:
$$\begin{gathered}
\phi = P + r \cdot U \hfill \\
\psi = Q + s \cdot V \hfill \\
\end{gathered}$$
then, if $U$ and $V$ are linear independent, their distance is given by:
$$d(\phi ,\psi ) = \frac{{\left| {(Q - P) \cdot U \times V} \right|}}{{\left\| {U \times V} \right\|}}$$
In my opinion it's important to make a difference between points and vectors. Because points are no vectors. Points can not be added. The difference between two points is a vector. And if I add to a point a vector I get a point. In your formula I would replace "vectors" $\overrightarrow {{v_1}} ,\overrightarrow {{v_2}} $ by points, because these are points. And points didn't have overarrows.
Thank you for listening!
Here's a solution, which I have also added to Wikipedia (https://en.wikipedia.org/wiki/Skew_lines#Nearest_Points), done completely using vectors without a need to solve equations.
Expressing the two lines as vectors:
Line 1: $\mathbf{v_1}=\mathbf{p_1}+t_1\mathbf{d_1}$
Line 2: $\mathbf{v_2}=\mathbf{p_2}+t_2\mathbf{d_2}$
The cross product of $\mathbf{d_1}$ and $\mathbf{d_2}$ is perpendicular to the lines.
$\mathbf{n}= \mathbf{d_1} \times \mathbf{d_2}$
The plane formed by the translations of Line 2 along $\mathbf{n}$ contains the point $\mathbf{p_2}$ and is perpendicular to $\mathbf{n_2}= \mathbf{d_2} \times \mathbf{n}$.
Therefore, the intersecting point of Line 1 with the above mentioned plane, which is also the point on Line 1 that is nearest to Line 2 is given by
$\mathbf{c_1}=\mathbf{p_1}+ \frac{(\mathbf{p_2}-\mathbf{p_1})\cdot\mathbf{n_2}}{\mathbf{d_1}\cdot\mathbf{n_2}} \mathbf{d_1}$
Similarly, the point on Line 2 nearest to Line 1 is given by (where $\mathbf{n_1}= \mathbf{d_1} \times \mathbf{n}$)
$\mathbf{c_2}=\mathbf{p_2}+ \frac{(\mathbf{p_1}-\mathbf{p_2})\cdot\mathbf{n_1}}{\mathbf{d_2}\cdot\mathbf{n_1}} \mathbf{d_2}$
Now, $\mathbf{c_1}$ and $\mathbf{c_2}$ form the shortest line segment joining Line 1 and Line 2.
Best Answer
You have correctly identified the vector perpendicular to both lines, i.e. $$\left(\begin{matrix}1\\-2\\1\end{matrix}\right)$$
Now find the vector joining any two point on the respective lines, for example, that joining $(0,0,0)$ and $(-1,0,0)$, therefore $$\left(\begin{matrix}1\\0\\0\end{matrix}\right)$$
and calculate the projection of this vector onto the normal.
Therefore the required distance is $$\frac{\left(\begin{matrix}1\\0\\0\end{matrix}\right)\cdot\left(\begin{matrix}1\\-2\\1\end{matrix}\right)}{\sqrt{1+4+1}}=\frac{1}{\sqrt{6}}$$