The form that this integral will take is
I=\int l^{2}\: dm
Where l is the distance from the axis of rotation.
Sorry, I am too lazy to draw any figures but here is one that will suffice.
In our case the distance from the axis of rotation (z) is given by
l=rsin\phi
as seen in the figure. We need to find dm now, and it is pretty easy. Use the volume element for spherical coordinates multiplied by the density. This is the little piece of mass.Density is given by
\rho=\frac{M}{\frac{4}{3}\pi R^{3}}So dm is
dm=\rho r^{2}sin\phi dr\:d\theta\:d\phiOur integral turns from this
I=\int l^{2}\: dm
into
I=\int (rsin\phi)^{2}\: \rho r^{2}sin\phi dr\:d\theta\:d\phiOf course this is not a single integral but a triple integral over our entire spherical volume. So
\rho \int^{\pi}_{0}\int^{2\pi}_{0}\int^{R}_{0} (rsin\phi)^{2}\: r^{2}sin\phi dr\:d\theta\:d\phi
And we can condense it some
\rho \int^{\pi}_{0}\int^{2\pi}_{0}\int^{R}_{0} r^{4}sin^{3}\phi \:dr\:d\theta\:d\phi
Now even further
\rho \int^{\pi}_{0}sin^{3}\phi\:d\phi \int^{2\pi}_{0}d\theta \int^{R}_{0} r^{4} \:dr
Solving a couple of the integrals
\frac{\rho2\pi\:R^{5}}{5} \int^{\pi}_{0}sin^{3}\phi\:d\phi
Now we just need to solve the last integral.
\int^{\pi}_{0}sin^{3}\phi\:d\phi
Convert
sin^{2}\phi=1-cos^{2}\phi
So
\int^{\pi}_{0}(1-cos^{2}\phi)sin\phi\:d\phi
Break up the integrals
\int^{\pi}_{0}sin\phi\:d\phi -\int^{\pi}_{0} cos^{2}\phi sin\phi\:d\phiThe first integral is equal to 2, and the second is equal to 2/3
\int^{\pi}_{0}sin\phi\:d\phi -\int^{\pi}_{0} cos^{2}\phi sin\phi\:d\phi=2-\frac{2}{3}=\frac{4}{3}
This means that the total integral (moment of inertia) is
I=\frac{\rho2\pi\:R^{5}}{5}\frac{4}{3}When we substitute in for rho we see that
I=\frac{M}{\frac{4}{3}\pi R^{3}}\frac{2\pi\:R^{5}}{5}\frac{4}{3}Which after canceling yields
I=\frac{2MR^{2}}{5}
If you want it for the case where it is merely a shell, don't do the integration over r, and multiply the result by dr.