system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: Elements want 8 electrons in their valence shell to become stable. Why do atoms want exactly 8 valence electrons, and why is it impossible to have 9 valence electrons?
gpt
The reason is to do with the quantum mechanics of how an electron bound to a nucleus behaves. The electron's wavefunction has to take the shape of a set of mathematical functions known as a spherical harmonics (you can Google these to see what they look like). The reason it's a spherical harmonic is that is has the right spherical symmetry.

Spherical harmonics are labelled with three numbers, which are conventionally called n, l, and m, where 0 <= l <= n, and -l <= m <= l.

At n=0, the only possible state is n=0, l=0, m=0 (I'll shorten this to (0,0,0)).

At n=1, the possible states are  (1,0,0) (1,1,-1) (1,1,0) (1,1,1).

Electrons have one additional property: spin. An electron can be either spin up (↑), or spin down (↓).

You'll hopefully notice at this point that means that for n = 1, there are 8 possible states, the four spherical harmonics * two spins. This is where the number 8 comes from. The 'n' parameter is what chemists would call the number of shells. You'll notice that for n > 1, you'll have even more states available, this is why things start to get more complex. Chemists call l = 0 the 's' orbital, l = 1 is 'p', l = 2 is 'd' and l = 3 is 'f', and the addition of these extra possible states makes chemistry of these things more interesting.

You should also note that this structure of states is what creates the shape of the periodic table, getting wider as you go down it; that's all to do with more spherical harmonic states becoming available.