A finite Monoid $M$ is a group if and only if it has only one idempotent element
If $M$ is not a group, then there is an element $a \in M$ with no inverse. Since $M$ is finite, there exists $n>m>0$ with $a^n=a^m$. You can now find a power of $a$ that is idempotent, and it cannot be the identity, because $a$ has no inverse.
Suppose that $a^m=a^n$ with $n>m$, and hence $a^m = a^{m+(n-m)}$.
We claim that $a^m=a^{m + k(n-m)}$ for all $k \ge 0$, and we prove this by induction on $k$. We have seen that it is true for $k=0,1$. Then, for $k>1$, we have, using the inductive hypothesis for $k-1$, $$a^{m + k(n-m)} = a^{m + (k-1)(n-m) + (n-m)} = a^{m+(k-1)(n-m)}a^{n-m} = a^ma^{n-m} = a^n = a^m$$ as claimed.
Now choose $k$ sufficiently large that $t := m + k(n-m) \ge 2m$. Then, multiplying both sides of $a^m=a^t$ by $a^{t-2m}$, we get $a^{t-m}=a^{2(t-m)}$, so $a^{t-m}$ is idempotent.
For example, if $a^7=a^9$, then $a^7=a^{15}$ and multiplying by $a$ gives $a^8=a^{16}$, so $a^8$ is idempotent.