  Faraday rotation studies of distant radio sources can constrain the evolution
and the origin of cosmic magnetism. We use data from the LOFAR Two Metre Sky
Survey: Data Release 2 (LoTSS DR2) to study the dependence of the Faraday
rotation measure (RM) on redshift. By focusing on radio sources that are close
in terms of their projection on the sky, but physically unrelated (random
pairs), we measure the RM difference, $\Delta$RM, between the two sources.
Thus, we isolate the extragalactic contribution to $\Delta$RM from other
contributions. We present a statistical analysis of the resulting sample of
random pairs and find a median absolute RM difference |$\Delta$RM| $ = (1.79
\pm 0.09)$ rad/m$^{2}$ , with |$\Delta$RM| uncorrelated both with respect to
the redshift difference of the pair and the redshift of the nearer source, and
a median excess of random pairs over physical pairs of $(1.65 \pm 0.10)$
rad/m$^{2}$. We seek to reproduce this result with Monte Carlo simulations
assuming a non vanishing seed cosmological magnetic field and a redshift
evolution of the comoving magnetic field strength that varies as $1/(1 +
z)^{\gamma}$. We find the best fitting results $B_0 \equiv B_{\rm comoving}(z =
0) \lesssim (2.0 \pm 0.2)$ nG and $\gamma \lesssim 4.5 \pm 0.2$ that we
conservatively quote as upper limits due to an unmodelled but non vanishing
contribution of local environments to the RM difference. A comparison with
cosmological simulations shows our results to be incompatible with primordial
magnetogenesis scenarios with uniform seed fields of order nG.
