TITLE: Non-abelian groups that are "closest" to being abelian
QUESTION [7 upvotes]: Given a finite, non-abelian group $G$ of order $n$, how close can $G$ be to being abelian? More formally, define the following density measure:
$$d(G) = \frac{\#\{(a, b) \mid a, b \in G, ab = ba\}}{n^2}$$
The question is, then, are there known upper bounds for $d(G)$? I suppose lower bounds might also be interesting. A naive lower bound for $d(G)$ would be $\frac{2n-1}{n^2}$, since the commutator is trivial whenever $a = b$ or $a = e_G$ -- is this tight (in whatever sense you see fit, e.g. asymptotically)?

REPLY [4 votes]: This is known as the commuting probability.  A strict upper bound is known: $d(G)\leq 5/8$ if $G$ is non-abelian, and $d(G)=1$ if $G$ is abelian.  This is mentioned both on the prior link, and is available on the SE.  Indeed, $$d(G)=5/8 \iff \text{Inn}(G)\cong \mathbb Z_2\times\mathbb Z_2,$$
which is implicitly proved on that aforementioned SE Q&A.  Some explicit examples include the quaternion and dihedral groups of order 8. 
As for lower bounds, consider this arxiv paper.  The introduction says that in the late 60's it was shown (by Erdos et al.) that
\begin{align}
d(G) \geq \frac{\text{log}_2\, \text{log}_2 |G|}{|G|}.
\end{align}
It also includes several references to other results on $d(G)$, including quite a number of characterizations and classifications for groups satisfying a certain upper bound.
This paper of Keller also includes and summarizes several results on lower bounds.
Going through those papers and their references should provide you with a wealth of results.