Statistical mechanics connects the microscopic world of atoms and molecules to macroscopic thermodynamic properties by averaging over all possible microstates. The fundamental postulate is that all accessible microstates of an isolated system are equally probable. The Boltzmann distribution p_i ∝ exp(−E_i/kT) gives the probability of finding a system in state i with energy E_i at temperature T. The canonical ensemble (constant N, V, T) is most useful for chemistry; its partition function Z = Σ exp(−E_i/kT) is the central object from which all thermodynamic properties are derived. Statistical mechanics provides the molecular-level interpretation of entropy: S = k ln Ω, where Ω is the number of microstates.
Work through the two-state system (e.g., a spin in a field) to understand how population ratios depend on temperature via the Boltzmann factor. Then generalize to a ladder of evenly spaced levels, which is the QHO partition function.
Statistical mechanics begins with a single, audacious postulate: for an isolated system in equilibrium, every accessible microstate is equally likely. A microstate specifies the exact quantum state of every particle — the position and momentum (or quantum number) of each atom. A macrostate is what you can actually measure: temperature, pressure, volume. The key insight is that macroscopic properties emerge from averaging over an enormous number of microstates, all equally probable.
From this postulate, the Boltzmann distribution follows. When your system is not isolated but is instead in thermal contact with a large reservoir at temperature T (the canonical ensemble — fixed N, V, T), you can ask: what fraction of time does the system spend in a microstate with energy Eᵢ? The answer is pᵢ = exp(−Eᵢ/kT) / Z, where Z = Σ exp(−Eᵢ/kT) sums over all microstates. The denominator Z is the partition function — a normalization constant, not a probability itself. Crucially, the exponential dependence on energy means that higher-energy states are populated exponentially less than lower-energy ones, but they are never completely empty at T > 0. This is the quantitative correction to the naive idea that "systems always sit in the lowest energy state."
The partition function Z is the central object in statistical mechanics precisely because every equilibrium thermodynamic property can be computed from it. The average energy ⟨E⟩ = −∂ ln Z/∂β (where β = 1/kT); the Helmholtz free energy A = −kT ln Z; entropy S = −∂A/∂T. This means that if you can evaluate Z — typically by modeling the energy levels of molecules — you can calculate heat capacities, equilibrium constants, and entropies from first principles. This is the bridge between quantum chemistry and thermodynamics.
Entropy now has a molecular interpretation: S = k ln Ω, where Ω is the number of microstates consistent with the observed macrostate. High entropy means many microstates look identical from outside — the system is "spread out" over many configurations. The second law becomes a probabilistic statement: isolated systems evolve toward macrostates with more microstates simply because, with all microstates equally likely, high-Ω macrostates are overwhelmingly more probable. The microscopic disorder that Boltzmann quantified is the same entropy Clausius defined thermodynamically.
A common conceptual pitfall is treating Z as a probability. It is not — individual Boltzmann weights divided by Z give probabilities, but Z itself is just the sum of all weights. Another subtlety: the canonical ensemble assumes the system can exchange energy (but not particles) with a reservoir. This is the most chemically relevant ensemble because most reactions happen at controlled temperature. The grand canonical ensemble (variable N) and microcanonical ensemble (fixed energy) are appropriate in other contexts, but canonical is the workhorse for molecular thermodynamics.