Why isn't just a fully occupied valence s orbital stable?
Elements with just 1 or 2 electrons in the most outer $\ce{s}$ orbitals, like $\ce{K}$ or $\ce{Ca}$, have very well screened off the central charge of the kernel. As consequence, the effective charge of the kernel and related energy needed to ionize the atom are relatively low.
OTOH, elements with just few missing electrons in the most outer $\ce{p}$ orbital, like $\ce{O}$ or $\ce{Cl}$, do not have well screened off the central kernel charge, which is relatively high, what leads to considerable electron affinity to some extra electrons.
Combining these 2 kinds of elements leads to energy release, as energy spent by ionization of the former is  compensated by energy release by capturing electrons by the latter and by a covalent contribution to the element bond.
In case of solid ionic compounds, there is additional large energy release du the ionic lattice energy.