This is in accordance with the Sunnah of Ibtila (Tests and Trials) of God in this world. A specific form of this law comes into play in the times of the rusul (Messengers) of God. At the behest of the Almighty, their propagation culminates in the worldly Judgement of their addressees and those who claim to profess faith in these messengers are, during the course of this propagation, put through certain trials and tests which are generally not faced by others. Consequently, the Quran says:
أَحَسِبَ النَّاسُ أَن يُتْرَكُوا أَن يَقُولُوا آمَنَّا وَهُمْ لَا يُفْتَنُونَ وَلَقَدْ فَتَنَّا الَّذِينَ مِن قَبْلِهِمْ فَلَيَعْلَمَنَّ اللَّهُ الَّذِينَ صَدَقُوا وَلَيَعْلَمَنَّ الْكَاذِبِينَ
Do people think that once they say: “We believe [in the rasul]”, they will be left alone and not be tried even though We [similarly] tried those who lived before them. So God will surely set apart the truthful, and He will also surely set apart the liars. (29:2-3)
Once the Messengers of God communicate the truth to their addressees to the extent that they are left with no excuse to deny it, this test manifests itself to isolate and discriminate the believers and the disbelievers before the latter are punished. The words of the above quoted verses: فَلَيَعْلَمَنَّ اللَّهُ الَّذِينَ صَدَقُوا وَلَيَعْلَمَنَّ الْكَاذِبِينَ (So God will surely set apart the truthful, and He will also surely set apart the liars) refer to this very reality. The implication is that before the judgement is delivered it is clearly known where each person stands. At certain other places in the Quran too, this law and practice of God is mentioned with similar emphasis:
وَلَنَبْلُوَنَّكُمْ بِشَيْءٍ مِّنَ الْخَوفِ وَالْجُوعِ وَنَقْصٍ مِّنَ الأَمَوَالِ وَالأنفُسِ وَالثَّمَرَاتِ وَبَشِّرِ الصَّابِرِينَ الَّذِينَ إِذَا أَصَابَتْهُم مُّصِيبَةٌ قَالُواْ إِنَّا لِلّهِ وَإِنَّـا إِلَيْهِ رَاجِعونَ
We shall test you with some fear and some famine and some loss of property and life and some loss in produce [from the fields]. And [O Prophet!] give glad tidings [of success in this world and in that to come] to those who persevere [in this cause]. [Those] who when afflicted with some calamity say: “We belong to God, and to Him [one day] we shall return.” (2:155-156)
__
For further details, please see:
Discussion 22229