If the compact connected group $K$ is second-countable (hence metrizable, hence Polish), one can prove it with pretty much straight measure theory. (I am not sure if this argument remains valid for non-metrizable groups.)

It's based on the following elementary lemma which is due (in some form) to Steinhaus:

**Lemma.** Let $G$ be a locally compact Polish group with a left-invariant Haar measure $\mu$, and $A \subset G$ be a Borel set with $\mu(A) > 0$. Then the set $A^{-1} A$ contains an open neighborhood of the identity. In particular, if $A$ is a subgroup of $G$ then $A$ is open.

You can find it as Exercise 17.13 (ii) in Kechris, *Classical Descriptive Set Theory*. You begin by showing that the function $x \mapsto \mu(xA \triangle A)$ is continuous, which uses the regularity of the measure or else Lusin's theorem. (The proof I know uses dominated convergence and hence only shows that this function is *sequentially* continuous, which is why I am unsure about the non-metrizable case.)

So let $E = \{(x,y) : xy = yx\} \subset K \times K$. This set is closed, and in particular, measurable. The probability of two elements commuting is $p = (\mu \times \mu)(E)$ where $\mu$ is the left Haar probability measure on $K$. Let $C_x$ denote the centralizer of $x$, which is closed. We have $(x,y) \in E$ iff $y \in C_x$, and thus by Fubini's theorem
$$p = \iint 1_E(x,y)\,\mu(dy)\,\mu(dx) = \iint 1_{C_x}(y)\,\mu(dy)\,\mu(dx) = \int \mu(C_x) \,\mu(dx).$$

If we suppose $p >0$, then the set $B = \{x : \mu(C_x) > 0\}$ must have positive measure. But if $\mu(C_x) > 0$, then by our lemma, $C_x$ is an open subgroup of $K$. It was already closed, and $K$ is connected, so $C_x = K$, i.e. $x$ is in the center $Z$ of $K$. Thus $B \subset Z$, so $Z$ is a closed subgroup with positive measure. Applying our lemma again, $Z$ is open and so $Z=K$, i.e. $K$ is abelian.

There is also be a "Baire category" analogue of this statement in the Polish case: if $E$ is nonmeager in $K \times K$, then $K$ is abelian. You could prove it by a nearly identical argument: use the Pettis lemma (Kechris 9.9) in place of Steinhaus above, and the Kuratowski-Ulam Theorem (Kechris 8.41) in place of Fubini. (Though maybe there's a simpler argument, since a nonmeager closed set has to have nonempty interior.)