If random variable $X$ has CDF $F(x)$, then $F^{-1}(U)$ is a sample of $X$ where $U$ is uniformly distributed on the unit interval. This is a standard result in probability theory, and I assume that you do not need a proof of this.
The CDF of a Rayleigh random variable $X$ is $$F(x) = 1 - \exp\left(-\frac{x^2}{2\sigma^2}\right), ~~x \geq 0,$$ and so $F^{-1}(y) = \sigma\sqrt{-2\ln(1-y)}$. But, since $1-U$ is also uniformly distributed on the unit interval, we save one subtraction by using $X = \sigma\sqrt{-2\ln( U})$ instead.