Muslim narrated in his Sahih and Al-Bayhaqiyy narrated in Kitab Al-Qadar from the route of Abu Aswad Ad-Du’aliyy:
“^Imran Ibnu Husayn said to me: ‘Do you see what the people are doing today, and that in which they are laboring? Is it something predestined for them that has come to pass on them, or among what they encounter [without destiny]? [Answer] with that with which their Prophet came to them, and by it the Evidence was established against them.’ I said, ‘It is something that has been destined for them and came to pass on them.’ Then ^Imran said, ‘Would that not have been injustice?’ I was very repelled by this question, and I said, ‘Everything is His creation and His ownership, He is not asked about what He Does, rather, they are the ones who will be asked.’ He said, ‘May Allah have Mercy on you, I did not mean anything by my question except to test your intellect. Certainly two men from the tribe of Muzaynah came to the Messenger of Allah and they said to him, “O Messenger of Allah, do you see what the people are doing today, and that in which they are laboring? Is it something predestined for them that has come to pass on them, or among what they encounter [without destiny]? [Answer] with that with which their Prophet came to them, and by it the Evidence was established against them.” He said, “In fact, it is something that has been ordained for them and came to pass on them, and what proves the truthfulness of that is the Saying of Allah:
﴿وَنَفْسٍ وَمَا سَوَّىٰهَا * فَأَلْهَمَهَا فُجُورَهَا وَتَقْوَىٰهَا﴾
[which means] ‘And I swear by the soul and what Created it [Allah], He is the one who inspired it with its wickedness and its piety.’”’”
And there is also the sahih hadith,
فمنْ وجَدَ خَيْرًا فليحمَدِ الله ومنْ وجدَ غيرَ ذلك فلا يلومَنَّ إلا نفسَه
[which means] “Whoever found goodness, then let him praise Allah, and whoever found other than that, let him blame noone but himself,” narrated by Muslim from the hadith of Abu Dharr from the Prophet from Allah. As for the first, and that is the one who found goodness, then he praises Allah because Allah is the one who is Generous to him by Creating and Giving him the success without any obligation on Him. So let the slave praise his Lord for His Generosity upon him. As for the second one, and he is the one who found evil, it is because Allah Made the evil inclination of the slave become clear by His Power. And so whomever Allah Misguided, that was by His Justice, and whomever He Guided, that was by His Generosity.
Had Allah Created the creation and Put a group of them in Paradise and a group of them in Hell based on His prior Knowledge, then the situation of the tortured among them would have been as Allah Described in the Qur’an when He Said:
﴿وَلَوْ أَنَّا أَهْلَكْنَاهُم بِعَذَابٍ مِّن قَبْلِهِ لَقَالُوا رَبَّنَا لَوْلَا أَرْسَلْتَ إِلَيْنَا رَسُولًا فَنَتَّبِعَ آيَاتِكَ مِن قَبْلِ أَن نَّذِلَّ وَنَخْزَىٰ﴾
(which means) “Had We Devastated them with a preemptive torture before they did anything, they would have said, ‘O our Lord! Had You only Sent to us a messenger, so that we would follow Your signs before we were degraded.”
So Allah Sent the Messengers as givers of good tidings and warners, so by the Sending of the Messengers Allah would make clear what was the readiness of the slave, whether obedience or refusal; thus, the one who is tortured would be tortured with evidence, and the one who lives in luxury would live in luxury with evidence. He Informed us that the fate of a portion of His creation is Hell because of the deeds they did by their choice, and He, the Exalted, was Knowledgeable with His Eternal Knowledge that they would not believe.
The Exalted Said:
﴿وَلَوْ شِئْنَا لَآتَيْنَا كُلَّ نَفْسٍ هُدَاهَا وَلَـٰكِنْ حَقَّ الْقَوْلُ مِنِّي لَأَمْلَأَنَّ جَهَنَّمَ مِنَ الْجِنَّةِ وَالنَّاسِ أَجْمَعِينَ﴾
[which means] “And had We Willed, We would have Given every soul its guidance; however, what I have Eternally Said will come into existence: ‘Certainly I will surely fill Hell with jinn and humans.’” In this verse Allah Informed that He Eternally Said, “Certainly I will surely fill Hell with jinn and humans,” and the saying of Allah is truth; He does not go back on His Word, because going back His Word, i.e., changing, would be lying in reference to Allah, and lying is impossible in reference to Him.
Allah the Exalted Said:
﴿قُلْ فَلِلَّـهِ الْحُجَّةُ الْبَالِغَةُ فَلَوْ شَاءَ لَهَدَاكُمْ أَجْمَعِينَ﴾
[which means] “[O Muhammad] say, Allah has the ultimate Evidence, and had He Willed He would have Guided all of you,” i.e., “He did not Will the guidance of all of you,” since that is not what He Knew would occur; and so the slaves are driven to do the deeds that occur from them by their choice, not by compulsion or coercion.