(No calamity occurs on the earth or in yourselves but it is inscribed in a record before We bring it into existence. Verily, that is easy for Allah.) (57:22) Allah said here,
مَا أَصَابَ مِن مُّصِيبَةٍ إِلَّا بِإِذْنِ اللَّـهِ ۗ وَمَن يُؤْمِن بِاللَّـهِ يَهْدِ قَلْبَهُ (And no calamity befalls [ one ], but with the leave of Allah. And whoever believes in Allah, He guides his heart…64:11) In other words, it is a reality that not even a particle can move without the Divine will. Without the will of Allah no one can harm or benefit anyone. If a person does not believe in Allah and the Divine destination, he would not have any means of comforting himself when a calamity befalls him. He receives it with despair, and gropes for means of alleviating it. A believer, on the other hand, who reposes his faith in Divine will and destination is guided by Allah, and his heart is filled with peace and tranquility. Allah will guide his heart to certainty that whatever difficulty afflicts him could never have missed him, and whatever adversity has missed him could never have afflicted him. As a result of this belief, he is promised a reward in the Hereafter, which he keeps in view all the time. This strong belief in the promise of a reward in the Hereafter alleviates the worst calamity of this world.
Tazkirul Quran
Maulana Wahiduddin KhanOn ayahs 11–13
No trouble arrives of its own accord. Every tribulation comes from God, and it afflicts man so that, through it, he should receive guidance. Trouble softens a man’s heart and jolts him out of his moral slumber. Trouble prods and sharpens a man’s mind. If he refrains from negative reaction, then trouble will become the best Divine instruction for him.
Uthmani text of the Madinah mushaf (King Fahd Complex). Translation: Saheeh International. Tafsir via Quran.com.