Solution (source code)

= Solution

For every $a\in\mathbb R$,
$$
X-a=(X-\mathbb EX)+(\mathbb EX-a).
$$
After squaring and taking expectations, the cross term vanishes because $\mathbb E[X-\mathbb EX]=0$. Therefore
$$
\mathbb E[(X-a)^2]
=\operatorname{Var}(X)+(\mathbb EX-a)^2.
$$
The second term is nonnegative and vanishes exactly at $a=\mathbb EX$, so the <variance as the minimum mean squared error of a constant> identity is
$$
\boxed{\ \operatorname{Var}(X)=\inf_{a\in\mathbb R}\mathbb E[(X-a)^2].\ }
$$