To show that group G is abelian if $(ab)^3 = a^3 b^3$ and the order of $G$ is not divisible by 3 
Let $G$ be a finite group whose order is not divisible by $3$.
  suppose $(ab)^3 = a^3 b^3$ for all $a,b \in G$. Prove that $G$ must be abelian.

Let$ $G be a finite group of order $n$. As $n$ is not divisible by $3$ ,$3$ does not divide $n$ thus $n$ should be relatively prime to $n$. that is gcd of an $n$ should be $1$.
  $n =  1 ,2 ,4 ,5 ,7 ,8 ,10 ,11, 13 ,14 ,17,...$
 further I know that all groups upto order $5$ are abelian and every group of prime order is cyclic. when it remains to prove the numbers which are greater than $5$ and not prime are abelian.
Am I going the right way?
 please suggest me the proper way to prove this.

I am reading "Topics in Algebra 2nd Edition" by I. N. Herstein.
This problem is the same problem as Problem 24 on p.48 in Herstein's book.
I solved this problem as follows:

$G\ni x\mapsto x^3\in G$ is a homomorphism since $(ab)^3=a^3b^3$ for all $a,b\in G$ by the assumption of this problem.
Assume that there exists $a\in G$ such that $a\ne e$ and $a^3=e$.
If $a^2=e$, then $a^3=a^2\cdot a=e\cdot a=a\ne e$.
But $a^3=e$ by our assumption.
So, $a^2\ne e$ must hold.
So, $o(a)=3$.
By a famous theorem, $o(a)\mid\#G$.
So, $3\mid\#G$.
But $3\not\mid\#G$ by the assumption of this problem.
So, this is a contradiction.
So, there does not exist $a\in G$ such that $a\ne e$ and $a^3=e$.
So, if $a^3=e$, then $a=e$ must hold.
So, the kernel of the homomorphism $G\ni x\mapsto x^3\in G$ is $\{e\}$.
So, the homomorphism $G\ni x\mapsto x^3\in G$ is injective.
Since $G$ is finite by the assumption of this problem, the homomorphism $G\ni x\mapsto x^3\in G$ is bijective.
Let $a,b\in G$.
$b(abab)a=(ba)^3=b^3a^3=b(bbaa)a$ by the assumption of this problem.
So, by the left cancellation law and the right cancellation law, we get $abab=bbaa$.
So, $(ab)^2=b^2a^2$ for any $a,b\in G$.
$(ab)^4=((ab)^2)^2=(b^2a^2)^2$.
Let $A:=b^2$ and $B:=a^2$.
Then, $(b^2a^2)^2=(AB)^2=B^2A^2=a^4b^4$.
So, $(ab)^4=a^4b^4$ for any $a,b\in G$.
$(ab)^4=a^4b^4=a(a^3b^3)b$.
$(ab)^4=a(bababa)b=a(ba)^3b$.
So, $a(a^3b^3)b=a(ba)^3b$.
By the left cancellation law and the right cancellation law, we get $a^3b^3=(ba)^3$ for any $a,b\in G$.
$(ba)^3=b^3a^3$ by the assumption of this problem.
So, $a^3b^3=b^3a^3$ for any $a,b\in G$.
Let $a,b\in G$.
Then, there exist $a^{'},b^{'}\in G$ such that $(a^{'})^3=a,(b^{'})^3=b$ since
$G\ni x\mapsto x^3\in G$ is surjective.
$ab=(a^{'})^3(b^{'})^3=(b^{'})^3(a^{'})^3=ba$.

