  We study the evolution of galaxies and the circumgalactic medium (CGM)
through cosmic time by correlating $\sim50,000$ MgII absorbers, tracers of cool
gas ($\sim10^{4}$~K), detected in the SDSS quasar spectra with galaxies
detected in the DESI Legacy Imaging Surveys. By doing so, we extract the
properties of galaxies associated with absorbers from redshift 0.4 to 1.3 with
effectively $\sim 15,000$ pairs and explore the covering fraction of MgII
absorbers as a function of galaxy type, stellar mass, impact parameter, and
redshift. We find that the gas covering fraction increases with stellar mass of
galaxies by $\sim M_{*}^{0.4}$. However, after we normalize the impact
parameter by the virial radius of dark matter halos, the gas profiles around
galaxies with masses ranging from $10^{9}$ to $10^{11} \, M_{\odot}$ become
weakly dependent on stellar mass. In addition, the gas distribution depends on
galaxy type: the covering fraction within $0.3 \, r_{vir}$ around star-forming
galaxies is 2-4 times higher than that around passive galaxies at all
redshifts. We find that the covering fraction of strong absorbers
($W_{\lambda2796}>1$ Angstrom) around both types of galaxies evolves
significantly with redshift, similarly to the evolution of star-formation rate
of galaxies, while such an evolution is not detected for weak absorbers
($W_{\lambda2796}<1$ Angstrom). We quantify the HI mass traced by strong
absorbers and find that the gas mass around galaxies evolves consistently with
the star-formation rate of galaxies. This result suggests that the properties
of galaxies and their CGM co-evolve through cosmic time. Finally, we discuss
the origins of strong absorbers around passive galaxies and argue that its
redshift evolution may trace the star-formation activity of satellite galaxies.
