[proofplan]
We prove both implications by expanding the definition of the commutator. If $G$ is abelian, then the middle factors in $ghg^{-1}h^{-1}$ can be rearranged so that each element cancels with its inverse. Conversely, if every commutator is the identity, then the equation $ghg^{-1}h^{-1}=e$ can be multiplied on the right by $h$ and then by $g$ to obtain $gh=hg$ for arbitrary $g,h \in G$.
[/proofplan]
[step:Use commutativity to show every commutator is the identity]
Assume that $G$ is abelian. Let $g,h \in G$ be arbitrary. Since $G$ is abelian, $hg^{-1}=g^{-1}h$. Therefore
\begin{align*}
[g,h]=ghg^{-1}h^{-1}=gg^{-1}hh^{-1}=ee=e.
\end{align*}
Since $g,h \in G$ were arbitrary, $[g,h]=e$ for every $g,h \in G$.
[/step]
[step:Use vanishing commutators to force every pair to commute]
Assume that $[g,h]=e$ for every $g,h \in G$. Let $g,h \in G$ be arbitrary. By the definition of the commutator,
\begin{align*}
ghg^{-1}h^{-1}=e.
\end{align*}
Multiplying this equality on the right by $h$ and using associativity gives
\begin{align*}
ghg^{-1}=h.
\end{align*}
Multiplying this equality on the right by $g$ and using associativity again gives
\begin{align*}
gh=hg.
\end{align*}
Since $g,h \in G$ were arbitrary, every pair of elements of $G$ commutes. Hence $G$ is abelian.
[guided]
Assume that $[g,h]=e$ for every $g,h \in G$. To prove that $G$ is abelian, we must prove that any two elements commute. Let $g,h \in G$ be arbitrary.
The hypothesis applies to this particular pair $g,h$, so expanding the definition of the commutator gives
\begin{align*}
ghg^{-1}h^{-1}=e.
\end{align*}
We want to extract the relation $gh=hg$ from this equation. First multiply both sides on the right by $h$. By associativity of the group operation and by the inverse identity $h^{-1}h=e$, the left-hand side becomes
\begin{align*}
(ghg^{-1}h^{-1})h=ghg^{-1}(h^{-1}h)=ghg^{-1}e=ghg^{-1}.
\end{align*}
The right-hand side becomes $eh=h$. Hence
\begin{align*}
ghg^{-1}=h.
\end{align*}
Now multiply both sides on the right by $g$. Again using associativity and $g^{-1}g=e$, we obtain
\begin{align*}
(ghg^{-1})g=gh(g^{-1}g)=ghe=gh.
\end{align*}
The right-hand side becomes $hg$. Therefore
\begin{align*}
gh=hg.
\end{align*}
Because the elements $g,h \in G$ were arbitrary, this proves that every pair of elements of $G$ commutes. By the definition of an [abelian group](/page/Abelian%20Group), $G$ is abelian.
[/guided]
[/step]
[step:Combine the two implications]
The first step proves that if $G$ is abelian, then $[g,h]=e$ for every $g,h \in G$. The second step proves that if $[g,h]=e$ for every $g,h \in G$, then $G$ is abelian. Therefore $G$ is abelian if and only if every commutator in $G$ is equal to the identity element $e$.
[/step]