The absorption of light by free carriers in semiconductors results in optical loss for all photon wavelengths. Since free-carrier absorption competes with optical transitions across the band gap, it also reduces the efficiency of optoelectronic devices such as solar cells because it does not generate electron-hole pairs. In this work, we develop a first-principles theory of free-carrier absorption taking into account both single-particle excitations and the collective Drude term, and we demonstrate its application to the case of doped Si. We determine the free-carrier absorption coefficient as a function of carrier concentration and we obtain excellent agreement with experimental data. We identify the dominant processes that contribute to free-carrier absorption at various photon wavelengths, and analyze the results to evaluate the impact of this loss mechanism on the efficiency of Si-based optoelectronic devices.