Despite their ubiquity throughout the Universe, the formation of S0 galaxies remains uncertain. Recent observations have revealed that S0 galaxies make up a diverse population that is difficult to explain with a single formation pathway, suggesting that the picture of how these galaxies form is more complicated than originally envisioned. Here, we take advantage of the latest hydrodynamical cosmological simulations and follow up these studies with an investigation into the formation histories of S0s in IllustrisTNG. We first classify IllustrisTNG galaxies in a way that is fully consistent with the observations, and reproduce the observed photometric and environmental distributions seen for the S0 population. We then trace the formation histories of S0 galaxies back through time, identifying two main distinct pathways: those that experienced gas stripping via group infalls (37 per cent of S0s) or significant merger events (57 per cent). We find that those forming via mergers feature a transient star-forming ring, whose present-day occurrence rate matches observations. We find that these formation pathways together can reproduce the range in rotational support in observed S0s, concluding that there are two main formation pathways for S0 galaxies.