ٱلَّذِى خَلَقَ ٱلْمَوْتَ وَٱلْحَيَوٰةَ لِيَبْلُوَكُمْ أَيُّكُمْ أَحْسَنُ عَمَلًۭا ۚ وَهُوَ ٱلْعَزِيزُ ٱلْغَفُورُ ﴿٢﴾
Who hath created life and death that He may try you which of you is best in conduct; and He is the Mighty, the Forgiving,
The test is not for Allah to learn something. It is for justice and for us: it turns what a person is into what a person does, so that deeds are real, written and witnessed. No one is judged for what they might have done. The Quran says the soul itself will be enough as a reckoner against a person.
Knowing what someone will do is not the same as making them do it. If Allah judged people by His foreknowledge alone, they could say, rightly, that they had not done the thing. The Quran says that on that Day the book will be placed, and the guilty will say: what kind of book is this that leaves nothing small or great but counts it, and they will find all they did present, 'and your Lord wrongs no one.' People are told to read their own book: 'Your own soul is sufficient as a reckoner against you today.' The test makes the verdict something the person can see for themselves.
The test also does something to the one tested. The Quran says that Allah created death and life to test which of you is best in deeds, and that We tried those before you, so that Allah makes known those who are sincere. Muslim scholars explain verses like 'until We know' as meaning that the matter becomes known and manifest in the world and in the record, not that Allah gains new information. Faith that is only claimed is different from faith that has been through difficulty and held: a person discovers their own sincerity, patience and gratitude only when tested.
A test in Islam is not only hardship. The Quran says: 'We test you with evil and with good as a trial,' so wealth, health, and power are tests too. An examiner may know how a student will do, but the student still has to sit the exam, since the work has to be done. The analogy is imperfect, as Allah is not learning anything, but it shows why a life of real choices matters.
ٱلَّذِى خَلَقَ ٱلْمَوْتَ وَٱلْحَيَوٰةَ لِيَبْلُوَكُمْ أَيُّكُمْ أَحْسَنُ عَمَلًۭا ۚ وَهُوَ ٱلْعَزِيزُ ٱلْغَفُورُ ﴿٢﴾
Who hath created life and death that He may try you which of you is best in conduct; and He is the Mighty, the Forgiving,
وَوُضِعَ ٱلْكِتَٰبُ فَتَرَى ٱلْمُجْرِمِينَ مُشْفِقِينَ مِمَّا فِيهِ وَيَقُولُونَ يَٰوَيْلَتَنَا مَالِ هَٰذَا ٱلْكِتَٰبِ لَا يُغَادِرُ صَغِيرَةًۭ وَلَا كَبِيرَةً إِلَّآ أَحْصَىٰهَا ۚ وَوَجَدُوا۟ مَا عَمِلُوا۟ حَاضِرًۭا ۗ وَلَا يَظْلِمُ رَبُّكَ أَحَدًۭا ﴿٤٩﴾
And the Book is placed, and thou seest the guilty fearful of that which is therein, and they say: What kind of a Book is this that leaveth not a small thing nor a great thing but hath counted it! And they find all that they did confronting them, and thy Lord wrongeth no-one.
وَكُلَّ إِنسَٰنٍ أَلْزَمْنَٰهُ طَٰٓئِرَهُۥ فِى عُنُقِهِۦ ۖ وَنُخْرِجُ لَهُۥ يَوْمَ ٱلْقِيَٰمَةِ كِتَٰبًۭا يَلْقَىٰهُ مَنشُورًا ﴿١٣﴾ ٱقْرَأْ كِتَٰبَكَ كَفَىٰ بِنَفْسِكَ ٱلْيَوْمَ عَلَيْكَ حَسِيبًۭا ﴿١٤﴾
And every man's augury have We fastened to his own neck, and We shall bring forth for him on the Day of Resurrection a book which he will find wide open. (And it will be said unto him): Read thy Book. Thy soul sufficeth as reckoner against thee this day.
كُلُّ نَفْسٍۢ ذَآئِقَةُ ٱلْمَوْتِ ۗ وَنَبْلُوكُم بِٱلشَّرِّ وَٱلْخَيْرِ فِتْنَةًۭ ۖ وَإِلَيْنَا تُرْجَعُونَ ﴿٣٥﴾
Every soul must taste of death, and We try you with evil and with good, for ordeal. And unto Us ye will be returned.
أَحَسِبَ ٱلنَّاسُ أَن يُتْرَكُوٓا۟ أَن يَقُولُوٓا۟ ءَامَنَّا وَهُمْ لَا يُفْتَنُونَ ﴿٢﴾ وَلَقَدْ فَتَنَّا ٱلَّذِينَ مِن قَبْلِهِمْ ۖ فَلَيَعْلَمَنَّ ٱللَّهُ ٱلَّذِينَ صَدَقُوا۟ وَلَيَعْلَمَنَّ ٱلْكَٰذِبِينَ ﴿٣﴾
Do men imagine that they will be left (at ease) because they say, We believe, and will not be tested with affliction? Lo! We tested those who were before you. Thus Allah knoweth those who are sincere, and knoweth those who feign.
وَلَنَبْلُوَنَّكُمْ حَتَّىٰ نَعْلَمَ ٱلْمُجَٰهِدِينَ مِنكُمْ وَٱلصَّٰبِرِينَ وَنَبْلُوَا۟ أَخْبَارَكُمْ ﴿٣١﴾
And verily We shall try you till We know those of you who strive hard (for the cause of Allah) and the steadfast, and till We test your record.