Property of abelianization
If $f : G \to H$ is a homomorphism to an abelian group, then $f(ab) = f(a) f(b) = f(b) f(a) = f(ba)$, hence $[a, b] \in \ker f$, hence $[G, G] \subseteq \ker f$. Is the rest clear from here?
This generalizes to any number of other situations: e.g., if $G$ is a group and $n\gt 0$ a positive integer, let $N$ be the subgroup of $G$ generated by all elements of the form $g^n$, with $g\in G$. Then $G/N$ has exponent $n$, and if $\pi\colon G\to G/N$ is the canonical surjection, then for any group $H$ of exponent $n$ and any group homomorphism $f\colon G\to H$, there exists a unique homomoprhism $F\colon G/N \to H$ such that $f=F\circ \pi$.
For the general context:
Definition. Let $F_{\infty}$ be the free group of countably infinite rank, and let $w\in F_{\infty}$. We say that $w$ is an identity of $G$ if and only if for every group homomorphism $f\colon F_{\infty}\to G$, we have $f(w)=1$. Equivalently, every evaluation of $w$ in $G$ is the identity.
Definition. Let $S\subseteq F_{\infty}$. The variety of groups determined by $S$ is the collection of all groups $G$ for which $w$ is an identity of $G$ for every $w\in S$.
Proposition. Let $S\subseteq F_{\infty}$. The variety of groups $\mathfrak{V}$ determined by $S$ satisfies:
- $\mathfrak{V}$ is closed under subgroups: if $G\in\mathfrak{V}$ and $H\lt G$, then $H\in\mathfrak{V}$.
- $\mathfrak{V}$ is closed under homomorphic images: if $G\in\mathfrak{V}$ and $\pi\colon G\to K$ is a surjective group homomorphism, then $K\in\mathfrak{V}$.
- $\mathfrak{V}$ is closed under arbitrary direct products: if $\{G_i\}_{i\in I}$ is a family of groups (of arbitrary size), and $G_i\in\mathfrak{V}$ for every $i\in I$, then $\prod\limits_{i\in I}G_i\in\mathfrak{V}$.
Birkhoff's HSP Theorem. Let $\mathcal{C}$ be a nonempty class of groups. Then $\mathcal{C}$ is a variety of groups if and only if $\mathcal{C}$ is closed under (H) homomorphic images, (S) subgroups, and (P) arbitrary direct products.
Proposition. Let $G$ be a group, and let $\mathfrak{V}$ be a variety of groups. Then there is a smallest normal subgroup of $G$, $\mathfrak{V}(G)$, such that $G/\mathfrak{V}(G)\in \mathfrak{V}$. If $\mathfrak{V}$ is determined as a variety by the set of identities $S\subseteq F_{\infty}$, then $\mathfrak{V}(G)$ is the subgroup of $G$ generated by the images of $S$ under all homomorphisms $F_{\infty}\to G$.
Proof. Clearly, there is at least one normal subgroup $N$ such that $G/N\in\mathfrak{V}$, namely $N=G$. If $\{N_i\}$ is a family of normal subgroups of $G$ such that $G/N_i\in\mathfrak{V}$ for every $i$, then $\prod (G/N_i)\in\mathfrak{V}$, since it's a product of groups in $\mathfrak{V}$. And the canonical map of $G$ into $\prod(G/N_i)$ has kernel $\cap N_i$, hence $G/N_i$ is isomorphic to a subgroup of a group in $\mathfrak{V}$, hence lies in $\mathfrak{V}$. Thus, we can take $\mathfrak{V}(G)$ to be the intersection of all normal subgroups $N\triangleleft G$ such that $G/N\in\mathfrak{V}$.
For the second description, let $f\colon F_{\infty}\to G$ be a homomorphism. Then $\pi\circ f\colon F_{\infty}\to G\to G/\mathfrak{V}(G)$ is a map from $F_{\infty}$ into a group in $\mathfrak{V}$, and since $S$ determines $\mathfrak{V}$, then $S$ must lie in th ekernel of this map. Hence $f(S)\subseteq \mathfrak{V}(G)$. That is, $\mathfrak{V}(G)$ contains all images of $S$ under homomorphisms $F_{\infty}\to G$. Now let $N$ be the subgroup generated by all such images. This group is normal, because if $f\colon F_{\infty}\to G$ is any homomorphism, then $f(S)^g$ is the image of $S$ under the homomorphism $\varphi_{g}\circ f$ (where $\varphi_g$ is the inner automorphism of $G$ determined by $g$), hence $f(S)^g\subseteq N$ for all $g\in G$. This holds for all $f$, so the generating set of $N$ is mapped to itself by conjugation. This shows that $N$ is normal; and $G/N\in\mathfrak{V}(G)$, because every homomoprhism $F_{\infty}\to G/N$ lifts to a homomorphism $F_{\infty}\to G$, and then the image of $S$ in $G/N$ is trivial. Therefore, $\mathfrak{V}(G)\subseteq N$, proving equality. QED
The normal subgroup $\mathfrak{V}(G)$ is called the verbal subgroup of $G$ corresponding to $\mathfrak{V}$.
Theorem. Let $G$ be a group, and let $\mathfrak{V}$ be a variety of groups. Then $\mathfrak{V}(G)$ is characterised by the following universal property: $\mathfrak{V}(G)\triangleleft G$, $G/\mathfrak{V}(G)\in\mathfrak{V}$, and for every $H\in\mathfrak{V}$ and every group homomorphism $f\colon G\to H$, there is a unique group homomorphism $F\colon G/\mathfrak{V}(G)\to H$ such that $f=F\circ \pi$, with $\pi\colon G\to G/\mathfrak{V}(G)$ the canonical projection.
Proof. First, we show $\mathfrak{V}(G)$ has this property. Let $H\in\mathfrak{V}(G)$, and let $f\colon G\to H$ be any group homomorphism. By the Isomorphism Theorem, $G/\mathrm{ker}(f)\cong f(G)\lt H$; since $f(G)$ is a subgroup of a group in $\mathfrak{V}$, then $f(G)\in\mathfrak{V}$, hence $G/\mathrm{ker}(f)\in\mathfrak{V}$ (it is isomorphic to a group in $\mathfrak{V}$). Since $\mathfrak{V}(G)$ is the smallest normal subgroup of $G$ with a quotient in $\mathfrak{V}$, then $\mathfrak{V}(G)\subseteq\mathrm{ker}(f)$, by the Universal property of the quotient, $f$ factors uniquely through $G/\mathfrak{V}(G)$, yielding $F$. That $\mathfrak{V}(G)\triangleleft G$ and $G/\mathfrak{V}(G)\in\mathfrak{V}$ has already been established.
Finally, we show that a normal subgroup $N$ satisfying this universal property is in fact $\mathfrak{V}(G)$. We know that $\mathfrak{V}(G)\subseteq N$ by construction. And by the universal property, the canonical projection $G\to G/\mathfrak{V}(G)$ factors through $G/N$, so $N\subseteq \mathfrak{V}(G)$, proving equality. QED
Now, the class of all abelian group is a variety (closed under homomorphism images, subgroups, and arbitrary direct products). In fact, the class is determined by the single identity $x^{-1}y^{-1}xy$: a group $G$ is abelian if and only if for every $g,h\in G$, $g^{-1}h^{-1}gh = 1$; if we let $\mathfrak{A}$ denote the variety of all abelian groups, then $\mathfrak{A}(G)$ is precisely the subgroup generated by all values of $x^{-1}y^{-1}xy$, i.e., the commutator subgroup. So the commutator subgroup has the desired universal property, hence $G^{\rm ab} = G/[G,G]$ has the desired universal property.
If you want to replace "abelian group" with "abelian group of exponent $n$", then you would use the set $S=\{x^{-1}y^{-1}xy, z^n\}$, and use the subgroup of $G$ generated by the commutators and all $n$th powers. If you replace "abelian group" with "nilpotent of class $c$", then you replace the commutator subgroup with the $(c+1)$st term of the lower central series, determined by the word $$[[\cdots [x_1,x_2],x_3]\cdots x_{n+1}].$$ And so on.
See also this discussion on commutator-center duality for more on varieties and verbal subgroups.