There are two parts to the answer to your question. (a) When solving a differential equation the boundary conditions must be specified (this is not always emphasised enough in textbooks), and (b) these conditions are determined by the physics of the problem via the postulates of quantum mechanics, including the nature of the wavefunction. Quantum mechanics (QM) has no derivation; we accept its postulates and QM survives only because experiment has so far always confirmed it.
As an example of quantisation consider the particle in a box. Here there are all sorts of solutions to the differential equation, i.e Schroedinger's equation. However, as the walls are infinitely high the wavefunction must have zero amplitude here and this means that the only solutions that remain and are physically realistic are when quantum number $n$ is quantised. The fact that the wavefunction must be zero at each wall are the boundary conditions.
A similar situation occurs on a particle on a ring where the angular momentum quantum number $l$ is quantised only because we insist, by applying the postulates of QM that the wavefunction repeats itself exactly each $2\pi$ round the circle. This is in effect the boundary condition.
In the H atom the equation is far more complicated but the general conditions imposed on the wavefunction remains the same; the imposition of boundary conditions, as determined by QM, results in the generation of integer quantum numbers so that theory matches experimental data.