Surah Al-A'raf, ayah 94

7:94

وَمَآ أَرۡسَلۡنَا فِي قَرۡيَةٖ مِّن نَّبِيٍّ إِلَّآ أَخَذۡنَآ أَهۡلَهَا بِٱلۡبَأۡسَآءِ وَٱلضَّرَّآءِ لَعَلَّهُمۡ يَضَّرَّعُونَ ٩٤

Wamā arsalnā fī qaryatim min nabiyyin illā akhadhnā ahlahā bil-ba'sā'i wad-darrā'i la'allahum yaddarra'ūn

And We sent to no city a prophet [who was denied] except that We seized its people with poverty and hardship that they might humble themselves [to Allāh].