How is the spherical coordinate metric tensor derived?

That is simply the metric of an euclidean space, not spacetime, expressed in spherical coordinates. It can be the spacial part of the metric in relativity.

We have this coordinate transfromation:

$$ x'^1= x= r\, \sin\theta \,\cos\phi =x^1 \sin(x^2)\cos(x^3) $$

$$x'^2= y= r\, \sin\theta \,\sin\phi =x^1 \sin(x^2)\sin(x^3)$$ $$x'^3= z= r\, \cos\theta = x^1\ \cos(x^2) $$

With $\, x^1=r, \quad x^2=\theta, \quad x^3=\phi \quad$ and $\quad x'^1=x, \quad x'^2=y, \quad x'^3=z$

Now you start from

$$ \eta_{ij} = \frac{\partial {x'^1}}{\partial {x^i}} \frac{\partial {x'^1}}{\partial {x^j}} +\frac{\partial {x'^2}}{\partial {x^i}}\frac{\partial x'^2}{\partial x^j} + \frac{\partial {x'^3}}{\partial {x^i}}\frac{\partial x'^3}{\partial x^j} $$

And doing it for each component you obtain the result you're looking for. I'll illustrate the case for $\eta_{22}$

$$ \eta_{22}= \frac{\partial {x'^1}}{\partial {x^2}} \frac{\partial {x'^1}}{\partial {x^2}} +\frac{\partial {x'^2}}{\partial {x^2}}\frac{\partial x'^2}{\partial x^2} + \frac{\partial {x'^3}}{\partial {x^2}}\frac{\partial x'^3}{\partial x^2} = \\ \frac{\partial {x}}{\partial {\theta}} \frac{\partial {x}}{\partial {\theta}} +\frac{\partial {y}}{\partial {\theta}}\frac{\partial y}{\partial \theta} + \frac{\partial {z}}{\partial {\theta}}\frac{\partial z}{\partial \theta} = \\ r^2 \cos^2\theta \, \cos^2\phi + r^2 \cos^2\theta \sin^2\phi + r^2 \sin^2\theta = r^2 $$

Where use has been made of the well known relation $\quad$ $\sin^2 \alpha +\cos^2\alpha=1$


In spherical one can show that the line element $$ ds^2=dx^2+dy^2+dz^2= dr^2+r^2d\theta^2+r^2\sin^2\theta\,d\phi^2= g_{ij}d\xi_id\xi_j $$ with $(\xi_1,\xi_2,\xi_3)=(x,y,z)$ or $(r,\theta,\phi)$, and the usual \begin{align} z&=r\cos\theta\, ,\qquad\qquad\qquad x=r\sin\theta\cos\phi\, ,\quad y=r\sin\theta\sin\phi\, ,\\ dz&=\cos\theta\,dr-r\sin\theta d\theta\qquad\hbox{etc.} \end{align} From $ds^2$ one can just read off the entries as the coefficients of $dr^2$, $d\theta^2$ and $d\phi^2$.