Quantum mechanical model of atom
To choose a more basic example, let us consider the particle in a box with 

\begin{equation}
V(x)={\begin{cases}0 &amp; 0\lt x \lt L\\\infty &amp; \text{otherwise}\end{cases}}
\end{equation}

To solve this we use the Schrödinger Equation

\begin{equation}
-\frac{\hbar^2}{2m}\frac{\partial^2}{\partial x^2}\psi(x)=E\psi(x)
\end{equation}

subject to the boundary conditions 
\begin{equation}
\psi(0)=\psi(L)=0. 
\end{equation}

The origin of these boundary conditions is, that the wave function needs to be a) continuous and and b) zero outside of the potential well, since probability goes to zero for an infinite potential.

As an ansatz for the wave function we take the solution of the free particle, i.e. planes waves:
\begin{equation}
\psi(x) = \exp\left(-ikx\right)
\end{equation}
with 
\begin{equation}
k^2=\frac{2mE}{\hbar^2}.
\end{equation}
What we now have is a periodic wave function, with period $L$ (or an integer multiple of that) due to the boundary condition, hence
\begin{equation}
kL = 2\pi n.
\end{equation}
At this point we have introduce the integer quantum number $n&gt;0$. With this we can now write down wave function and the corresponding energy. Both depend on $n$ and are therefore quantized.

So the origin of the quantized nature here are the boundary conditions. The quantum number naturally show up in the solution of the Schrödinger Equation. Obviously this can happen for other system, such as the Hydrogen atom as well.

As a final side note: The Schrödinger equation does not always lead to quantized solutions, it depends on the system. There are for example continuous states when considering the dissociation of molecules.