So, please don't ignore this question thinking it's a duplicate or something. I have read all the answers on StackExchange and in other articles, but either the math is too confusing, or the answers don't make sense.
So, I have a first course in Quantum Mechanics, and I am mostly following Griffiths for problems and theory. So, while reading about the infinite square well, I concluded that the reason why the energies in such problems (or say any problem with the Energy eigenfunctions equation/TISE) are quantized is because of the boundary continuity and normalizability. Because the energy eigenfunctions need to be continuous, we only take sine waves which start and end at 0 at the interface of the well, and that's why only specific energies are allowed.
But in one of the problems, he gives an unreasonably discontinuous function which doesn't even go to zero at the boundary as the initial wavefunction and mentions in a footnote, and I'm directly quoting from Problem 2.8, D.J. Griffiths, Introduction to QM, 2nd edition. -
A particle of mass $m$ in an infinite square well starts out in the left half of the well and is at $t=0$ equally likely to be found at any point in that region.
There is no restriction on the shape of the starting wave function as long as it is normalizable. In particular, $\psi(x,0)$ need not have a continuous derivative, in fact, $\psi(x,0)$ doesn't even have to be a continuous function.
Now if this is true about $t=0$, shouldn't this be true for any time? What is so special about $t=0$? But if the wavefunction doesn't need to be continuous, then our entire analysis of the infinite well energy eigenstates with quantized energies doesn't make any sense. So what are the conditions on a physical wavefunction and why do they exist?