We use a pressure-based model for splitting cold hydrogen into its atomic (HI) and molecular (H2) components to tackle the co-evolution of HI, H2, and star formation rates (SFR) in 3x10^7 simulated galaxies in the Millennium simulation. The main prediction is that galaxies contained similar amounts of HI at redshift z=1.5 than today, but substantially more H2, in quantitative agreement with the strong molecular line emission already detected in a few high-redshift galaxies and approximately consistent with inferences from studies of the damped Lyman-alpha absorbers seen in the spectra of quasars. The cosmic H2/HI ratio, i.e. Omega(H2)/Omega(HI), is predicted to evolve monotonically as (1+z)^1.6. This decline of the H2/HI ratio as a function of cosmic time is driven by the growth of galactic disks and the progressive reduction of the mean cold gas pressure. Finally, a comparison between the evolutions of HI, H2, and SFRs reveals two distinct cosmic epochs of star formation: an early epoch (z>3), driven by the evolution of Omega(HI+H2)(z), and a late epoch (z<3), driven by the evolution of Omega(H2)(z)/Omega(HI)(z).