Well it was that question that started the whole Quantum Theory off.So why does the electron not continue to collapse into the nucleus ?
The problem with Rutherford's Planetary model of the atom. The theory of electricity and magnetism predicted that opposite charges attract each other and the electrons should gradually lose energy and spiral inward. Moreover, it was reasoned that as a consquence atoms should give off a broad spectrum of colors as they do so. But no experiment could verify this rainbow.
In 1912 Niels Bohr suggested that since the electrons do not spiral into the nucleus there are some rules for what does happen. (This began a new scientific approach - rules need to be made up to fit the observation )
So Bohr said here are some rules that seem impossible, but they describe the way atoms operate, so let's pretend they're correct and use them.
RULE 1: Electrons can only orbit at certain allowed distances from the nucleus. Each orbit has a specific energy level
RULE 2: An Atom radiates energy (Light -EM) when an electron "drops" from a higher-energy orbit to a lower-energy orbit. Conversely an atom absorbs energy when an electron "leaps" from a low-energy orbit to a high-energy orbit. Thus Science took a Quantum Leap in the understanding of the atom.