Electrons orbit the nucleus of an atom due to the interplay between two fundamental forces: the electromagnetic force and the gravitational force. The gravitational force between the electrons and the protons is extremely weak compared to the electromagnetic force.
The electromagnetic force is responsible for the attraction between positively charged protons in the nucleus and negatively charged electrons. According to classical physics, an accelerating charged particle should continuously radiate energy in the form of electromagnetic radiation, which would cause the electron to spiral into the nucleus and eventually collapse.
However, classical physics fails to explain the stability of atoms and the discrete energy levels observed in atomic spectra. In the early 20th century, quantum mechanics was developed to describe the behavior of particles at the atomic and subatomic level.
In the framework of quantum mechanics, electrons are described by wave functions that determine the probability distribution of their positions around the nucleus. The wave functions are solutions to the Schrödinger equation, which accounts for the wave-particle duality of electrons. The allowed energy levels, or orbitals, of electrons in an atom are quantized and discrete.
Electrons occupy specific orbitals or energy levels, which are associated with certain amounts of energy. These orbitals have different shapes and orientations around the nucleus. The electron's behavior is best described as existing in a superposition of all possible orbitals until a measurement is made, at which point it collapses into a particular orbital.
The stability of the electron's orbit arises from the wave nature of particles and the concept of quantized energy levels in quantum mechanics. The electron's motion can be thought of as a standing wave around the nucleus, where the wave's crests and troughs determine the likelihood of finding the electron in a particular region.
In summary, the reason electrons orbit the nucleus rather than just sticking to the protons is due to the balance between the attractive electromagnetic force and the probabilistic behavior described by quantum mechanics.