Let $X$ be a random variable and $f, g: \mathbb{R} \rightarrow \mathbb{R}$ be increasing functions. Show that $cov(f(X), g(X)) \ge 0$.
The following hint was also provided: Assume $X$, $Y$ are independent and identically distributed, then show $E[(f(X)-f(Y))(g(X)-g(Y))] \ge 0$.
My attempt: Since $f$ and $g$ are increasing, then $(f(x) - f(y))(g(x) - g(y)) \ge 0$ for all $x, y \in \mathbb{R}$. Thus, $E[(f(X) - f(Y))(g(X) - g(Y))] \ge 0$ by the monotonicity of expectations.
Expanding, we get $E[f(X)g(X)]-E[f(X)g(Y)]-E[f(Y)g(X)]+E[f(Y)g(Y)] \ge 0$. Now due to independence, the LHS becomes $E[f(X)g(X)]-E[f(X)]E[g(Y)]-E[f(Y)]E[g(X)]+E[f(Y)g(Y)]$. Then due to identically distributed, the LHS further becomes $2E[f(X)g(X)]-2E[f(X)]E[g(X)]$. So together we have $2cov(f(X), g(X)) \ge 0$ and we are done.
My main query: This whole proof relies on the fact that $X$ and $Y$ are i.i.d. How can we just simply assume this? If we didn't make this assumption, then we would never have been able to break up the expectations and collect like terms. Is this proof correct or do I need a proof that does not rely on the iid of $X$ and $Y$?