Solution (source code)

= Solution

Choose a bounded strictly increasing function, for example $h(x)=\arctan x$. Independence and identical distribution imply $\operatorname{Var}(h(X)-h(Y))=2\operatorname{Var}(h(X))$. If $X=Y$ almost surely, the left side is zero. Therefore $h(X)$ is almost surely constant; injectivity of $h$ makes $X$ almost surely constant. Using a bounded function avoids any unassumed second moment of $X$.