The cosmic star formation rate density first increases with time towards a pronounced peak 10 Gyrs ago (or z=1-2) and then slows down, dropping by more than a factor 10 since z=1. The processes at the origin of the star formation quenching are not yet well identified: either the gas is expelled by supernovae and AGN feedback, or prevented to inflow. Morphological transformation or environment effects are also invoked. Recent IRAM/NOEMA and ALMA results are reviewed about the molecular content of galaxies and its dynamics, as a function of redshift. Along the main sequence of massive star forming galaxies, the gas fraction was higher in the past (up to 80%), and galaxy disks were more unstable and more turbulent. The star formation efficiency increases with redshift, or equivalently the depletion time decreases, whatever the position of galaxies, either on the main sequence or above. Attempts have been made to determine the cosmic evolution of the H2 density, but deeper ALMA observations are needed to effectively compare with models.