If the only purpose for mankind was to worship Allah, then why was mankind given freewill? Freewill gives man a chance to disobey and not worship Allah. Why would Allah allow that chance to exist if he knew that men who choose to not worship will have grave suffering?
Update: The answers seem to miss the question. The question is more about the reasoning behind giving freewill to the creation if the only purpose for mankind was to worship Allah.
Think about this. Let's say my wife and I have a choice to give birth to a robot or a human child. If my only purpose for having a child was for it to become a rich superstar then I would have a robot child which I can program to follow my orders. However, that's usually not the purpose of having a child. Parents usually want more from their children. One of their wants is for the child to love and respect them voluntarily.. Now, in that case, having a child with freewill makes sense! Why? Because if I'm a parent and I know that my child was programmed to love me it would not the same as if my child loved me voluntarily...