Was doing any sin previously written and predetermined by Allah? If the answer is yes, then why does Allah destine for some to commit sins, and for others to do good deeds, while we all are humans?.
One must believe in two things:
1 – That Allaah, may He be exalted, is the Creator of all things, and nothing happens in the universe except by His will. He knows what is to come and He decreed all of that and wrote it in a Book fifty thousand years before He created the heavens and the earth, as is stated in a saheeh report from our Prophet (peace and blessings of Allaah be upon him). He is Just and does not wrong anyone in the slightest, because He is independent of His creation and has no need of them. He is Kind and Gracious to them constantly, so how could He wrong them?
This principle is indicated by a great deal of evidence in the Qur’aan and Sunnah, such as the verses in which Allaah says (interpretation of the meaning):
“Verily, We have created all things with Qadar (Divine Preordainments of all things before their creation as written in the Book of Decrees ___ Al‑Lawh Al‑Mahfooz)”
“No calamity befalls on the earth or in yourselves but it is inscribed in the Book of Decrees (Al‑Lawh Al‑Mahfooz) before We bring it into existence. Verily, that is easy for Allaah”
And the Prophet (peace and blessings of Allaah be upon him) said: “Allaah decided the decrees of creation fifty thousand years before He created the heavens and the earth. He said: And His Throne is above the water.” Narrated by Muslim (2653).
2 – Man has free will and choice by means of which he does some things and refrains from others, and he believes or disbelieves, and he obeys or disobeys, for which he will be brought to account and rewarded or punished, although Allaah knows what he will do, what he will choose and what his ultimate destiny will be. But Allaah does not compel him to do evil, or to choose kufr, rather He clearly shows him the path and He has sent Messengers and revealed Books, and shown him the right way. Whoever goes astray does so to his own loss,.
Allaah says (interpretation of the meaning):
“And say: ‘The truth is from your Lord.’ Then whosoever wills, let him believe; and whosoever wills, let him disbelieve”
“Verily, We showed him the way, whether he be grateful or ungrateful”
“So whosoever does good equal to the weight of an atom (or a small ant) shall see it.
8. And whosoever does evil equal to the weight of an atom (or a small ant) shall see it”
“And it will be cried out to them: ‘This is the Paradise which you have inherited for what you used to do’”
“so taste you the abiding torment for what you used to do”
Allaah tells us that man believes and does righteous deeds by his own choice and free will, then he enters Paradise, or he disbelieves and does evil deeds by his own choice and free will, then he enters Hell.
Every person knows in his own heart and by looking at those around him, that our deeds – good and evil, obedient and sinful – are done by our own choice, and we do not feel that there is any force compelling us to do them. You can curse, swear, lie and backbite, just as you can praise Allaah, glorify Him, pray for forgiveness, speak the truth and give sincere advice. You can walk to places of idle entertainment, falsehood and evil, just as you can walk to the mosques or places of goodness and obedience. A man can strike with his hand, steal, speak falsehood and betray, or he can help the needy, do good and do favours with his hands. Everyone does some of these deeds and he does not feel that he is compelled or forced, rather he does them by his own free will and then he will be called to account for them; if they were good, then the consequences will be good, and if they were bad then the consequences will be bad.
What Allaah has decreed is something that man cannot know and he cannot base his deeds on it or use it as an excuse. It is also not valid for him to object to his Lord by questioning why He has caused someone to be among the doomed or the blessed. Allaah has not wronged the one who is doomed, rather He gave him time and ability and freedom of choice, and He sent to him Messengers and revealed Books to them, and He reminded him and warned him with all kinds of reminders, such as calamities and tests, so that he would repent to Him and turn to Him. If he chose the path of misguidance, and followed the way of criminals, he only harmed himself, and he is the one who has caused his own doom, as Allaah says (interpretation of the meaning):
“Indeed he succeeds who purifies his ownself (i.e. obeys and performs all that Allaah ordered, by following the true Faith of Islamic Monotheism and by doing righteous good deeds).
10. And indeed he fails who corrupts his ownself (i.e. disobeys what Allaah has ordered by rejecting the true Faith of Islamic Monotheism or by following polytheism, or by doing every kind of evil wicked deeds)”
[al-Shams 91:9, 10]
“Allaah wronged them not, but they wronged themselves”
[Aal ‘Imraan 3:117]
“Has not the story reached them of those before them? — The people of Nooh (Noah), ‘Aad, and Thamood, the people of Ibraaheem (Abraham), the dwellers of Madyan (Midian) and the cities overthrown [i.e. the people to whom Loot (Lot) preached]; to them came their Messengers with clear proofs. So it was not Allaah Who wronged them, but they used to wrong themselves”
To sum up: the belief that Allaah is the Creator Who has decreed all things and has distinguished those who are blessed from those who are doomed, does not mean that Allaah forces His slaves to obey or disobey. Rather He has given them the ability to choose and free will, which is what they act upon, and for which they will be brought to account. Your Lord does not wrong His slaves.
See also the answer to question no. 96989.
And Allaah knows best.