I found out that the equation $(AB-BA)^m=I_n$ does have solution when $n=km$, where $k$ is an arbitrary integer number.
To prove, we just need to consider $C=$diag($r_1,..., r_m$) where $r_1,..., r_m$ are the roots of $x^m-1=0$, i.e., the eigenvalues of matrix $C$.
In this case we know trace($C$)=0, and so there is two matrices $A$ and $B$ such that $C=AB-BA$, and also it is vivid that $C^m=I_m$. For each $n=km$, we can duplicate the matrix $C$, $k$ times to get an $mk\times mk$ matrix to consider as a new matrix $C$.
Now, my question is this:
Does the equation $(AB-BA)^m=I_n$ have answer if and only if $n=mk$?