Why did God give free will to commit atrocities like theft and murder?

Human beings are the best of Allah’s creations if they obey him. He favored us over even His angels who worship Him submissively. The qualities God gave us – intellect and free will – make us superior to His other creatures. When Allah decided to place mankind on the earth as His deputy, the angels objected under the assumption that this creature – who has been given choice and intellect – would be a cause of corruption and suffering on earth. The angels asked Allah as mentioned in the Qur’an.

And [mention, O Muhammad], when your Lord said to the angels, "Indeed, I will make upon the earth a deputy (vicegerent)." They said, "Will You place upon it one who causes corruption therein and sheds blood, while we declare Your praise and sanctify You?" Allah said, "Indeed, I know that which you do not know." Surah Baqarah, chapter 2, verse 30. 

Allah Almighty said “I know that which you do not know” denoting that the benefit of creating this type of creature – which they did not have knowledge of – outweighs the harm that they mentioned. He would create among them Prophets and send Messengers; and people who are truthful, martyrs, righteous believers, worshippers, the modest, the pious, the scholars who implement their knowledge, humble people, and those who love Allah and follow His Messengers. There is wisdom behind all the decisions Allah makes.

Out of His wisdom, He created us as intellectual beings rather than programmed machines that serve their purpose without any feelings or thought. We cannot say that a robot that is programmed to serve a disabled person is a compassionate robot or a computer that is programmed to follow our orders is a loyal computer.  Humans are given the ability to think about and comprehend the realities of life; to feel and understand the emotions of love, hate, happiness, sorrow, and so on. Allah gave us choice so that we may worship Him and obey Him with clear understanding which is more befitting, meaningful, and rewarding.

There is a narration of the prophet (peace be upon him) which says: 

Abu Huraira reported Allah's Messenger (peace be upon him) as saying:
No child is born but upon “Fitrah”. He then said. Recite: “The nature made by Allah in which He created man, there is no altering of Allah's nature; that is the right religion”, the verse from Surah Rum." Sahih Muslim 2658.

Allah created mankind inherently good. The word “Fitrah” mentioned in the narration means natural instinct, as in, human nature. Indeed, it is human nature to recognize the existence of God, believe in Him alone and do righteous deeds. The circumstances and surroundings one is brought up in and the choices one makes are the deciding factors for how one ends up in life – good or evil.  God provided us with intellect and choice for us to choose to believe in Him and worship Him or to reject Him, after fully understanding and comprehending the reality of this life, without any compulsions.

The free will or choice given to us can be used both ways, either for success or self-destruction. He did not create us and grant us free will to be transgressors and commit crimes. That is the reason God sent messengers and prophets to remind and guide humanity through His revelations – the last one being the Qur’an – so that we may make the right choices and save ourselves from destruction. So, if people choose to disbelieve in Allah and commit crimes or harm others while they have a clear understanding of right and wrong, they will be the ones responsible for their own actions – not God. Allah states in the Qur’an;

“Indeed, Allah does not wrong the people at all, but it is the people who are wronging themselves”. Surah Younus, chapter 10, verse 44.

Most importantly, this life a test for us. We are being tested throughout our lives to see who turns obediently towards God and who turns away from Him in disobedience according to our own free will. Hence, Allah delegated will to humankind to be used in the service of good. Our will is “free will” in the sense that we are not forced to do what we do. We are rewarded or punished in the Hereafter based upon what we did with our God-given will. Allah knows best.  May Allah guide us.