Allah tests those he loves. Ustadh Michael Wolfender recites from Surah At-Taghabun (64 The Mutual Disillusion) explaining that no situation happens except with the permission of Allah. Whoever believes in Allah, He guides his heart. Continue to obey Allah and His messenger ﷺ.
We can achieve contentment and happiness in this life, even with hardships which can make us better.