  The non-linear relation between the X-ray and ultraviolet (UV) luminosity in
quasars has been used to derive quasar distances and to build a Hubble diagram
at redshifts up to $z\sim$ 7. This cosmological application is based on the
assumption of independence of the relation on redshift and luminosity. We want
to test the reliability of this hypothesis by studying the spectroscopic
properties of high-redshift quasars in the X-ray and UV bands. We performed a
one-by-one analysis of a sample of 130 quasars at $z>$ 2.5 with high-quality
X-ray and UV spectroscopic observations. We found that not only the X-ray to UV
correlation still holds at these redshifts, but its intrinsic dispersion is as
low as 0.12 dex (previous works reached 0.20$-$0.22 dex). For a sample of
quasars at $z\sim$ 3 with particularly high-quality observations the dispersion
further drops to 0.09 dex, a value entirely accountable for by intrinsic
variability and source geometry effects. The composite spectra of these
quasars, in both the X-rays and the UV, do not show any difference with respect
to the average spectra of quasars at lower redshifts. The absence of any
spectral difference between high- and low-$z$ quasars and the tightness of the
X-ray to UV relation suggests that no evolutionary effects are present in the
relation. Therefore, it can be safely employed to derive quasar distances.
Under this assumption, we obtain a measurement of the luminosity distance at
$z\sim$ 3 with 15 % uncertainty, and in a 4$\sigma$ tension with the
concordance model.
