Does anyone know how this function is arrived at? Was it experimental?
Note that the wave function is not an observable and so cannot be arrived at experimentally.
The Schrödinger equation for the 1D potential well is given by:
$$-\frac{\hbar}{2m}\frac{\text{d}^2 \psi}{\text{d}x^2}=E\psi$$
Slightly re-written:
$$\psi''+k^2\psi=0\tag{1}$$
where:
$$k^2=\frac{2mE}{\hbar}$$
$(1)$ is a second order, linear, homogeneous differential equation and any decent math textbook will tell you it has the following solution, thus not experimentally obtained:
$$\psi(x)=A\sin kx + B\cos kx$$
where $A$ and $B$ are integration constants.
One of these values is determined by means of the boundary conditions $\psi(0)=\psi(L)=0$ (assuming the wave function acts on the domain$[0,L])$. So-called normalisation then determines the other.