As Muslims, we believe that Almighty Allah has the absolute knowledge of what happened and what is going to happen and what would happen in case something else did not happen.
nothing happens in this universe without Allah’s will and it is His will that He gave people the ability to choose between right and wrong; thus, people will be held accountable based on their own choices. Almighty Allah says, [And shown people the two ways (i.e. the good and evil paths)] (Al-Balad 90:10).
Sheikh Muhammad Nur Abdullah, former president of ISNA (the Islamic Society of North America) and member of the Fiqh Council of North America, stated: This is a complicated issue that requires a high level of trust and submission to the will and wisdom of Allah. The whole concept of qadar (Arabic for: destiny) is based on the belief in Allah as having the absolute knowledge and wisdom, and therefore we owe him worship and servitude.
Human beings are created with freewill. Allah created us and showed us right from wrong, and He gave us the ability to choose between them. Allah says, [And shown him the two ways (i.e. the good and evil paths)] (Al-Balad 90:10). He also blessed us with the instrument of choosing and distinguishing between right and wrong — that is the faculty of understanding. A sane person is able to make choices, and therefore, he or she is judged accordingly, whereas an insane person is absolved from such accountability since he or she lacks the faculty of understanding by which distinction between right and wrong is performed.
Allah’s knowledge is unlimited. He is the Omniscient, and therefore He knows everything about His servants. However, Allah judges us for what we willingly choose to do, and not according to what He knows we will do. Even when we think of something evil, we will not be judged until this evil thought has been put into practice. If the evil thought is not carried out, it is forgiven. So we have to differentiate between Allah’s knowledge and Allah’s will.
As for Adam, of course, Allah knew Adam would eat from the tree, but Allah did not force him to eat, and Allah did not punish him until after Adam actually ate from it. The Qur’an (Ta-Ha 20:115) tells us that Adam “did forget,” and in another verse (Ta-Ha 20:121) it tells us that “Adam disobeyed his Lord.” However, Adam repented (Ta-Ha 20:122) and Allah accepted his repentance.
In brief, we are instructed to follow Allah’s commandments; do what we have been ordered to do and avoid what we have been forbidden to do. If we do anything bad, it is because of our wrong choice: [Whatever good, (O people!) happens to you, is from Allah; whatever evil happens to you, is from your (own) soul. And We have sent you [Prophet Muhammad] as a Messenger to (instruct) humankind. And it is sufficient that Allah is the witness.] (An-Nisaa’ 4:79).