This isn't an easy question, and the fact that you're asking it means you're paying attention to the world. Allah tests the people He loves — not because they did something wrong, but because hardship can polish a heart the way nothing else can.
There's a story I want to share with you.
Hana's grandmother had been sick for a long time. Hana was the kind of girl who helped without being asked — she brought tea, she read out loud, she sat through long quiet afternoons when nobody else would. And still, her grandmother got worse, not better.
One night Hana sat on the prayer mat after Isha and didn't say any of the duas she knew. She just said, It isn't fair. Then she sat there, embarrassed, because she'd never spoken to Allah like that before.
Her father found her later and didn't try to fix it. He said the prophets had asked harder questions than that, and Allah had loved them through every one. Hana thought about that for a long time. The fairness didn't come back. But something else did — a steadiness, small and warm, that she could carry into the room with her grandmother the next morning.
Where this comes from
-
Qur'an 2:155 — Allah promises a test, and gives the believers the news of patience.
وَلَنَبْلُوَنَّكُم بِشَيْءٍ مِّنَ الْخَوْفِ وَالْجُوعِ وَنَقْصٍ مِّنَ الْأَمْوَالِ وَالْأَنفُسِ وَالثَّمَرَاتِ ۗ وَبَشِّرِ الصَّابِرِينَ
Allah will test all of us with a little fear, a little hunger, a little less of what we own, or losing people we love. The ones who hold steady through it — give them the good news.
Look this up on quran.com - Sahih al-Bukhari 5645 — "No fatigue, nor disease, nor sorrow… befalls a Muslim, except that Allah expiates some of his sins for that." Look this up on sunnah.com