The identification between $S^2$ and $\mathbb{C}$ is called the streographic projection, and it assigns the point $w=x+iy=(x,y,0)$ to the 2nd intersection point of the sphere $S^2$ with the line connecting the north pole $(0,0,1)$ to $(x,y,0)$. The parametrization of this line is $$t\mapsto (0,0,1)+t(x,y,-1)=(tx,ty,1-t)$$

So if $(tx,ty,1-t)\in S^2 $ then $$ t^2 x^2 +t^2 y^2 + (1-t)^2 =1 \implies (1+|w|^2)t^2 -2t =0 \implies t=0, {2\over 1+|w|^2 }$$

But $t=0$ corresponds to north pole, so the point on $S^2$ assigned to $w=x+iy$ is $$ ({2x\over |w|^2+1 },{2y\over |w|^2+1 },{|w|^2-1\over |w|^2+1 })$$

Conversely the point in $\mathbb{C}$ assigned to $(x,y,z)\in S^2 -\{(0,0,1)\}$ is the intersection of the line passing through $(x,y,z),(0,0,1)$ with the plane $z=0$. The line is (This is a different parametrization of the same line above. Note that $x,y$ are not the same in the two parametrizations.) $$t\mapsto (0,0,1)+t(x,y,z-1)=(tx,ty,tz+1-t)$$

And the intersection point is attained when $tz+1-t=0$ or $t={1\over1-z}$. So the point in $\mathbb{C}$ assigned to $(x,y,z)\in S^2 -\{(0,0,1)\}$ is $$({x\over1-z},{y\over1-z},0)={x\over1-z}+i{y\over1-z}=:w $$

Note that $$ |w|^2 ={x^2+y^2\over (1-z)^2}$$

Now $$ {1\over w}={1\over |w|^2}\big({x\over1-z}-i{y\over1-z}\big)=(1-z)\big({x\over x^2+y^2}-i{y\over x^2+y^2}\big)$$

And the point on $S^2$ corresponding to this complex number is (note that $|{1\over w}|={1\over |w|}$) $$ ({{2x(1-z)\over x^2+y^2}\over {1\over |w|^2}+1 },{{-2y(1-z)\over x^2+y^2}\over {1\over |w|^2}+1 },{{1\over |w|^2}-1\over {1\over |w|^2}+1 }) \\ =\Big({2x(1-z)\over (1-z)^2+x^2+y^2 },{-2y(1-z)\over (1-z)^2+x^2+y^2 },{(1-z)^2-x^2-y^2\over (1-z)^2+x^2+y^2)}\Big)$$

which is the desired mapping from $S^2$ to $S^2$ (excluding the north and the south pole of the sphere which correspond to $\infty$ and 0 of the complex plane.)