Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:7:168

And We divided them throughout the earth into nations. Of them some were righteous, and of them some were otherwise. And We tested them with good ˹times˺ and bad that perhaps they would return ˹to obedience˺.  

And We divided them, We separated them, into communities, sects, in the earth. Some of them are righteous, and some of them, people ˹who˺, are otherwise, disbelievers and wicked individuals. And We tried them with good things, with graces, and evil things, with misfortunes, so that they might revert, from their wickedness.
القرآن:٧:١٦٨

وَقَطَّعْنَاهُمْ فِي الْأَرْضِ أُمَمًا ۖ مِنْهُمُ الصَّالِحُونَ وَمِنْهُمْ دُونَ ذَٰلِكَ ۖ وَبَلَوْنَاهُمْ بِالْحَسَنَاتِ وَالسَّيِّئَاتِ لَعَلَّهُمْ يَرْجِعُونَ  

{وقطَّعناهم} فرَّقناهم {في الأرض أُمما} فرقا {منهم الصالحون ومنهم} ناس {دون ذلك} الكفار والفاسقون {وبلوناهم بالحسنات} بالنعم {والسيئات} النقم {لعلهم يرجعون} عن فسقهم.