Finite Groups with exactly nn conjugacy classes (n=2,3,…)(n=2,3,…)

I am looking to classify (up to isomorphism) those finite groups $G$ with exactly 2 conjugacy classes.

If $G$ is abelian, then each element forms its own conjugacy class, so only the cyclic group of order 2 works here.

If $G$ is not abelian, I am less sure what is going on. The center $Z(G)$ is trivial since each of it’s elements also form their own conjugacy class. Now assume $G-\{1_G\}$ is the other conjugacy class.

The Class Equation says $|G|=|Z(G)|+\sum [G:C_G(x)]$ where the sum is taken over representatives from the conjugacy classes (not counting the singleton ones from the center). (Here $C_G(x)=\{g\in G~|~gx=xg\}$ is the centralizer of $x$ in $G$.)

For us this simplifies to $|G|-1=[G:C_G(x)]$ for any $x\in G-\{1_G\}$. Therefore $|C_G(x)|=\frac{|G|}{|G|-1}$ is an integer. But this can only happen when $|G|=2$ which we have already covered. So does this mean up to isomorphism there is only one group with 2 conjugacy classes?

If so, how would the argument change if we allowed 3 conjugacy classes?

Nice question! The $n = 3$ case is fun and I think small values of $n$ are going to make very good exercises so I encourage you to work on them yourself, but if you really want to know a solution….
If $H_1, H_2$ denote the stabilizers of the non-identity conjugacy classes with $|H_1| \le |H_2|$, then the class equation reads $|G| = 1 + \frac{|G|}{|H_1|} + \frac{|G|}{|H_2|}$, or
The reason this is useful is that if either $|G|$ or $|H_1|$ gets too big, then the terms on the RHS become too small to sum to $1$. Since we know that $|G| \ge 3$, it follows that we must have $|H_1| \le 3$; otherwise, $\frac{1}{|H_1|} + \frac{1}{|H_2|} \le \frac{1}{2}$ and the terms can’t sum to $1$.
Now, if $|H_1| = 2$ then $|H_2| \ge 3$, hence $|G| \le 6$. Since every group of order $4$ is abelian we can only have $|G| = 6, |H_2| = 3$. The unique nonabelian group of order $6$ is $S_3$, which indeed has $3$ conjugacy classes as desired.
If $|H_1| = 3$, then $|G| \ge 3$ implies $|H_2| \le 3$, hence $|H_2| = |G| = 3$ and $G = C_3$.