Jensen's Inequality (with probability one)

Let $f : \mathbb{R} \to \mathbb{R}$ be convex. This means that at every point $a \in \mathbb{R}$, there is an affine linear function $l_a : \mathbb{R} \to \mathbb{R}$ which is dominated by $f$, i.e. $$ l_a(x) \leq f(x) $$ and $l_a(a) = f(a)$. When $f$ is differentiable, for example, then $l_a$ is the tangent to $f$ at $a$.

When $f$ is strictly convex, we have the additional condition $$ l_a(x) = f(x) ~\Rightarrow ~ x = a $$ Before we define $a$ in this particular problem (and sweeping integrability problems under the rug), notice that $$ l_a(X) \leq f(X) $$ holds, hence $E l_a(X) \leq E f(X)$. Moreover $E l_a(X) = l_a(E X)$ because of the linearity of $l_a$. Finally, we set $a = EX$, and have obtained $$ f(EX) \leq E f(X) $$ Suppose now that $f(EX) = E(fX)$, which can be written as $E l_a(X) = E f(X)$ with our choice $a = E X$.

With this setup, consider $E [f(X) - l_a(X)] = 0$. Inside the expectation we have a nonnegative random variable (because of convexity) and it has expectation zero. We conclude that $f(X) = l_a(X)$ almost everywhere (because we used the integral to do so! the integral doesn't see measure zero sets.)

Now we use strict convexity: $f(X) = l_a(X) ~\Rightarrow~ X = a = EX$ almost surely, i.e. $X$ is a constant.

Addendum: Claim: If $Y$ is a nonnegative-valued random variable and $E Y = 0$, then $Y = 0$ almost surely.

To see this, let $A_n = \{Y \geq 1/n\}$, i.e. the set where $Y$ is greater than $1/n$. Note that $\cup_n A_n = A := \{Y > 0\}$. Let's show that $P A_n = 0$ for any $n$, where $P$ is the probability measure.

$$ \frac{1}{n} P A_n \leq E (Y I_{A_n}) \leq E Y = 0 $$ Now recall that $P \cup_n A_n \leq \sum_n P A_n$, which is often called the 'countable subadditivity' property. This implies that $P A = 0$, and the claim follows.