Initially a phenomenological guess to explain the periodic table. Later it was apparently proven properly with the spin-statistics theorem, physics.stackexchange.com/questions/360140/theoretical-proof-of-paulis-exclusion-principle.
And it was understood more and more that basically this is what prevents solids from collapsing into a single nucleus, not electrical repulsion: electron degeneracy pressure!
Bibliography:
- www.youtube.com/watch?v=EK_6OzZAh5k How Electron Spin Makes Matter Possible by PBS Space Time (2021)