Why The Perfect God Would Punish Wrongdoers?
Allah chose for human to test them and set reward and punishment. This was His will. Why He did, because He wanted to do it, and also to show his bounty. Since he is just, so he will not punish anyone who has valid excuses. He will punish only the rebellious ones, who knowingly went against him.