Trap an electron inside a width L, with walls placed so high that it cannot get out. This is called a potential well.
The electron inside is a wave. Since it cannot get out at either end, the wave has to be 0 there. It becomes a wave with a node fixed at each end, which is the same standing wave as on a plucked string.
Only particular wavelengths can become a standing wave. For the same reason that the notes on a string are discrete, the wavelength of a trapped electron is discrete as well.
For both ends to be nodes, the width of the well has to be a whole number of half wavelengths. That is L = n\dfrac{\lambda}{2}.
Solving for the wavelength gives \lambda_n = \dfrac{2L}{n}. The longest is n = 1, and raising n makes it shorter.
The momentum is p_n = \dfrac{h}{\lambda_n} = \dfrac{nh}{2L}. Simply by being trapped, the momentum can take discrete values only.
Inside the walls the potential energy is 0, so all of it is kinetic energy. Putting this into E = \dfrac{p^2}{2m} gives E_n = \dfrac{n^2h^2}{8mL^2}.
Growing as the square of n, the levels spread further apart the higher they go. In the hydrogen atom they crowded together toward the top, and here it is the other way round. A different way of trapping gives a different arrangement.
The reason they come out discrete is the same as for the atom. What changed is only that fitting a whole number of waves around a circumference became reaching 0 at both ends. A condition was placed on a wave, and that is why the result is discrete.
n = 0 is not allowed. It would make the wave 0 everywhere, which would mean there is no electron at all. The lowest is n = 1, with E_1 = \dfrac{h^2}{8mL^2}.
This is not 0. A trapped electron cannot bring its motion to a stop even in its lowest state. This E_1 is called the zero-point energy.
The uncertainty principle says the same thing. Trap it in a width L and \Delta x comes to about L, so \Delta p comes to about \dfrac{h}{L}. The energy is about \dfrac{(\Delta p)^2}{2m}, the same order as E_1.
E_n is inversely proportional to L^2. Narrow the well and every level rises at once.
The tighter the space it is pushed into, the more violently the electron moves. That also means a force appears that resists the trapping. This is why atoms and molecules do not collapse below a certain size.
Work it out at the size of an atom, 10^{-10} m, and E_1 comes to a few eV. That is the same order as the energy of the light atoms take in and give out, so even this simple model gets the order right.