Liquid oxygen, poured between the poles of a strong magnet, sticks there: $\mathrm{O_2}$ is paramagnetic, so by Orbital Diagrams and Magnetism it must have unpaired electrons. Yet its Lewis structure, $\mathrm{O{=}O}$ with every electron paired, says it has none. Valence bond theory can't fix this; molecular orbital theory can.
🔑 Key idea
Atomic orbitals on two atoms combine into the same number of molecular orbitals spread over the whole molecule: bonding orbitals (lower energy, electron density between the nuclei) and antibonding orbitals (marked *, higher energy, a node between the nuclei). Fill them like atomic orbitals (lowest first, Pauli, Hund). Then $$\text{bond order} = \tfrac{1}{2}\left(\text{bonding electrons} - \text{antibonding electrons}\right).$$
💡 Why it works
Electrons are waves. Two waves that overlap in step add up between the nuclei, piling electron density where it attracts both nuclei: that lowers the energy, a bonding orbital. Out of step, they cancel between the nuclei, leaving a node; the electrons are pushed outward and the energy rises, an antibonding orbital. Each electron in a bonding orbital helps hold the atoms together and each one in an antibonding orbital undoes about as much, which is where the bond-order formula comes from. A bond order of zero means no bond: $\mathrm{He_2}$ doesn't exist.
Oxygen's MO diagram for the valence electrons. The last two go into the two π* orbitals, one each with parallel spins (Hund's rule): two unpaired electrons, and bond order $(8 - 4)/2 = 2$.
For the second-row diatomics the valence orbitals fill in this order: $\sigma_{2s}, \sigma^*_{2s}$, then for $\mathrm{B_2}$, $\mathrm{C_2}$ and $\mathrm{N_2}$: $\pi_{2p}, \sigma_{2p}$ (2s and 2p mixing pushes $\sigma_{2p}$ up), and for $\mathrm{O_2}$ and $\mathrm{F_2}$: $\sigma_{2p}, \pi_{2p}$; then $\pi^*_{2p}, \sigma^*_{2p}$.
✏️ Worked example: Oxygen
Find the bond order and the number of unpaired electrons in $\mathrm{O_2}$.
Bond order $= (2 - 1)/2 = \tfrac{1}{2}$, greater than zero.
Answer: Yes, with a weak half bond (it has been observed in gas discharges).
⚠️ Common mistake
Predicting from the Lewis structure that $\mathrm{O_2}$ has no unpaired electrons. Lewis structures pair every electron by design, so they miss the two electrons that occupy separate $\pi^*$ orbitals. Use the MO diagram whenever magnetism or bond order of a diatomic is the question. Check: count electrons into the $\pi^*$ pair; 1, 2 or 3 of them leave unpaired electrons.
Practice
Pass with 3 right answers, the last 2 in a row. Each right answer earns 3 XP.