Here is the theorem that we are going to prove.

Theorem. Let V be a subspace in a Euclidean vector space W and let w be a vector from W. Let w=v+v' where v is the projection of w onto V and v' is the normal component (as in the theorem about orthdogonal complements). Then ||v'|| is the distance from w to V and v is the closest to w vector in V.
Proof. Since v'=w-v, ||v'|| is the distance from w to v. By definition the distance from w to V is the smallest distance dist(w,p) for all p in V. Therefore ||v'|| is not smaller than the distance from w to V.

We need to show that ||v'|| is not greater than dist(w,p) for any vector p in V. Take any vector p in V. Then

dist(w,p)2 = ||w-p||2 = ||w-v+v-p||2 = ||v'+v-p||2= (v'+v-p)*(v'+v-p) = v'*v' + v'*(v-p) + (v-p)*v + (v-p)*(v-p)

Since v and p are in V and since V is a subspace, v-p is also in V. Since v' is in the orthogonal component V', v' is orthogonal to v-p. Therefore

dist(w,p)2 = v'*v' + (v-p)*(v-p) = ||v'||2 + ||v-p||2.

Since ||v-p||2 is non-negative, we can conclude that ||v'|| does not exceed dist(w,p)2 as required. Thus indeed, ||v'|| coincides (not greater and not smaller than) the distance from w to V.

Since ||v'||=dist(w,v), v is a vector from V which is closest to w. In order to prove that v is the only such vector, take an element p from V again. As we know,

dist(w,p)2 = ||v'||2 + ||v-p||2.

If dist(w,p)=dist(w,v)=||v'|| then ||v-p||=0 and by one of the properties of norms v-p=0 or v=p. Thus v is the closest to w vector from V.