We study the contribution of galaxies with different properties to the global densities of star formation rate (SFR), atomic (HI) and molecular hydrogen (H2) as a function of redshift. We use the GALFORM model of galaxy formation, which is set in the LCDM framework. This model includes a self-consistent calculation of the SFR, which depends on the H2 content of galaxies. The predicted SFR density and how much of this is contributed by galaxies with different stellar masses and infrared luminosities are in agreement with observations. The model predicts a modest evolution of the HI density at z<3, which is also in agreement with the observations. The HI density is predicted to be always dominated by galaxies with SFR<1Msun/yr. This contrasts with the H2 density, which is predicted to be dominated by galaxies with SFR>10Msun/yr. Current high-redshift galaxy surveys are limited to detect carbon monoxide in galaxies with SFR>30Msun/yr, which in our model make up, at most, 20% of the H2 in the universe. In terms of stellar mass, the predicted H2 density is dominated by massive galaxies, Mstellar>10^10Msun, while the HI density is dominated by low mass galaxies, Mstellar<10^9Msun. In the context of upcoming neutral gas surveys, we suggest that the faint nature of the galaxies dominating the HI content of the Universe will hamper the identification of optical counterparts, while for H2, we expect follow up observations of molecular emission lines of already existing galaxy catalogues to be able to uncover the H2 density of the Universe.