Why atom has the straight discrete energy levels? Interaction between a nucleus and electrons is in gravity(not considering) and electrostatics. Due to electrostatics nucleus attracts electrons. The force that describes this process is
$$F=k\dfrac{q_1 \, q_2}{r^2}$$
What I want to say, is that, the force is "smooth" depending on distance: it doesn't looks like a sinusoidal, I mean there are no strongly-marked values.
Why, then atom has a the straight discrete energy levels?
 A: To simplify for you: a large number of electrons populating for example the surfaces of two  spheres will exert forces upon each other just as you describe.
The picture begins to change when we focus instead on the behavior of a single electron, and it changes completely when we confine that single electron to a very small volume of space- as for example when it is orbiting close to the nucleus of an atom, under the attractive influence of the protons in that nucleus.
That is when we discover that the electron, when confined in this way, cannot possess any energy level it wants, but instead is forced to possess energies which are discontinuous and discrete- and which we can observe and measure as the so-called "line spectrum" of that atom. 
Quantum mechanics was invented to furnish an accounting of why those energy levels were discrete, and a host of other things that physicists had discovered but could not explain using the tools that worked well for large objects consisting of trillions of atoms.
A: The coulomb force is not only " "smooth" depending on distance: it doesn't looks like a sinusoidal, I mean there are no strongly-marked values." In a real experiment of two macroscopic charges under an attractive potential, there will be acceleration and a continuous radiating spectrum, the two charges neutralizing each other with big sparks.
At the microscopic level commensurate with h, the planck constant, instead of the electron falling on the proton with a continuous radiative spectrum and neutralizing it, one observes discrete spectra, not predictable by Maxwell's equations.  
The classical mathematical model had to be modified, first with the Bohr atom, which postulated stable orbits,still thinking classically, and then with the solutions of the schrodinger equation which developed into the theory of quantum mechanics, postulates and all.
The difference introduced  with quantum mechanics is that it is all about probabilities, i.e. orbitals, and not orbits. It is a predictive theory which determines probabilities for finding a system in a specific state.These  probabilities have a wave nature, manifest in the single particle at a time double slit experiment, and as far as the spectra go, the wavefunctions give the probabilities for transition from one spectral line to the other.
It is an observational fact that there are discrete energy levels, and quantum mechanics models them successfully, and predicts innumerable other possible observations correctly. Similar to the  a falling apple: it is an observational fact modeled  by Newtons gravitational laws which predict successfully all new possibilities of gravitational interactions in their range of validity .
