Spherical harmonics as orthonormal basis in quantum mechanics In this article https://mrtrix.readthedocs.io/en/dev/concepts/spherical_harmonics.html the following statement is given:

Spherical harmonics are special functions defined on the surface of a sphere. They form a complete orthonormal set and can therefore be used to represent any well-behaved spherical function.

I have two questions:
1. What does it means "functions defined on the surface of a sphere"? Functions whose domain is given by $(\theta,\phi)$ with $\theta \in [0, \pi]$ and $\phi \in [0,2\pi]$?
2. Why spherical harmonics form an orthonormal basis for the space of functions defined on the sphere? Since spherical harmonics are also simultaneous eigenfunctions of operators $L^2$ and $L_z$, don't they form a basis for any function?
 A: 
What does "functions defined on the surface of a sphere" mean?

You can literally define the spherical harmonics on a sphere:
In your article, the following formula is given:
$$Y_l^m(\theta,\phi) = \sqrt{\frac{(2l+1)}{4\pi}\frac{(l-m)!}{(l+m)!}} P_l^m(\cos \theta) e^{im\phi}$$
Clearly, $Y(\theta,\phi)$ is well defined for all $(\theta,\phi)\in\mathbb R\times\mathbb R$. On the other hand\begin{align}F\colon[0,\pi]\times\mathbb R&\to S\\(\theta,\phi)&\mapsto\begin{pmatrix}\sin\theta\cos\phi\\\sin\theta\sin\phi\\\cos\theta\end{pmatrix}\end{align} is a surjective function to the sphere. Thus, if a spherical harmonic $Y$ is constant on the level sets of $F$, we can define $Y$ on the sphere by requiring that $$(Y\circ F)(\theta,\phi)=Y(\theta,\phi)$$for all $(\theta,\phi)\in[0,\pi]\times\mathbb R$ (note the slight abuse of notation).
Well, it turns out that spherical harmonics are indeed constant on level sets of $F$: For the north pole and the south pole, you can find the explanation here and for the other points on the sphere - i.e. the points with $0<\theta<\pi$ - this is easy to prove.
