The wave functions of electrons and protons in a hydrogen atom are such that the probability of finding an electron at the same location as a proton is very small. This is because the wave functions of electrons and protons have different shapes, and they are also separated by a region of space known as the "Bohr radius." The Bohr radius is the average distance between the electron and the proton in a hydrogen atom.
The laws of quantum mechanics also prevent the electron from spiraling into the proton. This is because the electron has a certain amount of angular momentum, which is a measure of its rotation. The angular momentum of the electron keeps it in orbit around the proton.
In classical physics, an electron would spiral into the proton because it would be constantly losing energy through electromagnetic radiation. However, in quantum mechanics, the electron can only lose energy in discrete amounts, known as quanta. The amount of energy that the electron can lose is determined by the difference between the energy levels of the electron's orbits. The energy levels of the electron's orbits are quantized, which means that they can only have certain values.
The lowest energy level of the electron in a hydrogen atom is known as the "ground state." The electron cannot lose energy and spiral into the proton unless it has enough energy to reach the next energy level, which is known as the "excited state." The energy required to excite the electron to the next energy level is greater than the energy that the electron can lose through electromagnetic radiation. This is why the electron does not spiral into the proton.