IR spectroscopy in the range 12-230 µm with the SPace IR telescope for Cosmology and Astrophysics (SPICA) will reveal the physical processes that govern the formation and evolution of galaxies and black holes through cosmic time, bridging the gap between the James Webb Space Telescope (JWST) and the new generation of Extremely Large Telescopes (ELTs) at shorter wavelengths and the Atacama Large Millimeter Array (ALMA) at longer wavelengths. SPICA, with its 2.5-m telescope actively-cooled to below 8 K, will obtain the first spectroscopic determination, in the mid-IR rest-frame, of both the star-formation rate and black hole accretion rate histories of galaxies, reaching lookback times of 12 Gyr, for large statistically significant samples. Densities, temperatures, radiation fields and gas-phase metallicities will be measured in dust-obscured galaxies and active galactic nuclei (AGN), sampling a large range in mass and luminosity, from faint local dwarf galaxies to luminous quasars in the distant Universe. AGN and starburst feedback and feeding mechanisms in distant galaxies will be uncovered through detailed measurements of molecular and atomic line profiles. SPICA's large-area deep spectrophotometric surveys will provide mid-IR spectra and continuum fluxes for unbiased samples of tens of thousands of galaxies, out to redshifts of z∼6. Furthermore, SPICA spectroscopy will uncover the most luminous galaxies in the first few hundred million years of the Universe, through their characteristic dust and molecular hydrogen features.