“Do the people think that they will be left to say: We believe, and they will not be tried? But We have certainly tried those before them, and Allah will surely make evident those who are truthful, and He will surely make evident the liars.” (Surah Al-Ankabut, 2-3)
Allah tests humans with both calamities and blessings to determine who will be patient and thankful and who will be impatient and ungrateful.
Allah also indicates, “Your wealth and your children are but a trial, and Allah has with Him a great reward.” (Surah At-Taghabun, 15)