Why do atoms on the periodic table have the number of valence electrons that they do? I'm studying year 11 and am learning about valence electrons and how these electrons drive intermolecular bonds.
What I have not been able to find an explanation to is why all the elements on the periodic table have the number of valence electrons that they do.
To me, it seems intuitive that if the halides are so eager to gain an electron, why would their natural state not be to have the 8th electron in their shell?
Atoms have protons (and neutrons) in the nucleus that define the element. For example, Fluorine always nine protons. The number of electrons must balance the number of protons in the atomic state. If fluorine had ten electrons, i.e. a full inner and outer shell, it would be a negative ion with net charge -1, so the electrostatic charge would repel the last electron.
It is only with the help of other atoms nearby that charges can be (almost) balanced. In $\ce{LiF}$, the fairly positively charged $\ce{Li+}$ ion attracts the comparatively negatively charged $\ce{F-}$ ion, so there is no net unbalance in a crystal of $\ce{LiF}$, though in each pair, the valence electron spends most time in the outer shell of fluorine.