Magnetic fields are observed everywhere in the Universe from the smallest in stars and planets to the fields present in the largest cosmic structures and in the voids between them. If the origin of the fields of stars and planets is well understood, the question is still open as to how the fields can be originated on cosmological scales of the order of Kpc in the galaxies up to the Mpc of magnetic fields measured in clusters of galaxies, filaments and large-scale structure voids. One of the most interesting possibilities is that these fields are none other than the relics, post-processed by the formation of structures, of magnetic fields generated in the primordial Universe during inflation or during phase transitions before recombination. The characteristics of these Primordial Magnetic Fields (PMFs) are closely related to the mechanism that generated them and therefore to the fundamental physics involved in the early Universe. In this sense, primordial magnetic fields represent an observational window on fundamental physics. With their presence the PMFs influence all the formation of the structures and in particular one of the best observables is the Cosmic Microwave Background radiation (CMB) on which they have numerous effects both on the angular power spectrum and on the non-Gaussianity. At OAS Bologna we have a team of excellence in this topic. We have developed the first analytical treatment of perturbations induced by magnetic fields (Finelli et.al 2008, Paoletti et al. 2009), some analytical treatments of non-Gaussianities (Caprini et al. 2009) and we have developed two of the main codes for the study of primordial magnetism: one at the level of gravitational effects (Finelli et al. 2008, Paoletti et al 2009) and one related to the effects of PMFs on the thermal history of the Universe (Chluba et al 2015, Paoletti et al. 2019). We were among the first to derive the constraints on the characteristics of primordial magnetic fields with the real data from CMB (Paoletti & Finelli 2011 and 2013, Paoletti et al. 2019, Paoletti and Finelli 2019) and we had the leadership of the project dedicated to the study of PMFs in the Planck Collaboration completed by the publication of the dedicated article (Planck 2015 results XIX). At the moment we are dealing with the preparation of future data and the improvement of the theoretical treatment (Paoletti and Finelli 2019). Thanks to the connections with the University we also provide the characteristics of the magnetic fields constrained with the CMB as initial conditions for large-scale simulations to obtain the fields observed today (Hutschenreuter et al. 2018).