Hund's rule
Hund's rule says that when electrons are filling a set of orbitals of equal energy — say the three p orbitals or five d orbitals of a subshell — they spread out one to each orbital before any orbital takes a second electron, and the unpaired electrons all keep their spins pointing the same way. Electrons claim their own rooms before agreeing to share. Only once every orbital in the subshell holds one electron do they start to pair up.
The reason is energy. Two electrons crammed into the same orbital are close together and repel each other strongly, costing energy, so nature prefers to keep them apart in separate orbitals. There is also a subtler quantum bonus, called the exchange energy, that lowers the energy further when parallel-spin electrons stay unpaired. Both effects push toward the same arrangement: maximum spreading and maximum aligned spin.
This rule explains why so many atoms have unpaired electrons and therefore feel a magnetic pull. Iron, with several unpaired d electrons, owes its magnetism in part to Hund's rule, and the same principle governs the colours and reactivity of countless compounds. Alongside the Aufbau order and the exclusion principle, it completes the small set of rules from which every ground-state electron configuration can be built.
Electrons singly occupy equal-energy orbitals with aligned spins before any pairing begins.
The energy gain comes mainly from the quantum exchange effect, not simply from electrons avoiding each other's charge; the two parts are easy to conflate but are genuinely distinct.