speaking on the knowledge of Allah and freedom of the people to choose or act, we would like to quote Sheikh Ahmad Kutty, an Islamic scholar, who stated,

Allah tells us in the Qur’an that while nothing happens in the world without His will, including whatever we do, He wills that we should exercise our choice; He also tells us that He will either reward us or punish us according to our acts based on our own will. In other words, since we have been given the freedom and ability to choose, we are accountable for the way we exercise the same. Almighty Allah says,
[Say: “Truth is from your Lord.” Now whosoever will, may believe, and whosoever will, may disbelieve.] (Al-Kahf 18: 29)
[And by the soul and Him that formed it, inspiring it with the thought of what is good for it and the thought of what is bad for it: Successful indeed is the one who purifies it, and wretched is the one who debases it.] (Ash-Shams 91: 7-11)

In conclusion, while it is true that everything happens in conformity with the supreme will of Allah, we are accountable for our actions, since we have the freedom to choose and act. This is in accordance with Allah’s justice as He endowed us with conscience, whereby we know what is right and what is wrong.

Besides, He also endowed us with our rational faculties and sent down revelations, whereby He has communicated His will for us. Hence, we are accountable for our actions.