The most striking feature of the Cosmic Star Formation History (CSFH) of the Universe is a dramatic drop of the star formation (SF) activity, since z~1. In this work we investigate if the very same process of assembly and growth of structures is one of the major drivers of the observed decline. We study the contribution to the CSFH of galaxies in halos of different masses. This is done by studying the total SFR-halo mass-redshift plane from redshift 0 to redshift z~1.6 in a sample of 57 groups and clusters by using the deepest available mid- and far-infrared surveys conducted with Spitzer MIPS and Herschel PACS and SPIRE. Our results show that low mass groups provide a 60-80% contribution to the CSFH at z~1. Such contribution declines faster than the CSFH in the last 8 billion years to less than 10% at z<0.3, where the overall SF activity is sustained by lower mass halos. More massive systems provide only a marginal contribution (<10%) at any epoch. A simplified abundance matching method shows that the large contribution of low mass groups at z~1 is due to a large fraction (>50%) of very massive, highly star forming Main Sequence galaxies. Below z~1 a quenching process must take place in massive halos to cause the observed faster suppression of their SF activity. Such process must be a slow one though, as most of the models implementing a rapid quenching of the SF activity in accreting satellites significantly underpredicts the observed SF level in massive halos at any redshift. Starvation or the transition from cold to hot accretion would provide a quenching timescale of 1 Gyrs more consistent with the observations. Our results suggest a scenario in which, due to the structure formation process, more and more galaxies experience the group environment and, thus, the associated quenching process. This leads to the progressive suppression of their SF activity shaping the CSFH below z~1.