I believe the Islamic concept of life being a test is one of the most powerful concepts in philosophy of religion. It has a lot of ramifications in discussions concerning purpose/value of life, the problem of evil, Divine Hiddenness, and middle knowledge. Even outside the realm of philosophy, I believe it's an incredibly empowering concept in one's spiritual life. Understanding and developing this idea with philosophical rigor can be considered a valuable project in and of itself. One way of doing that is responding to objections. That leads to refinement of any model.
So let's talk about the problem in the post title. Islam teaches three important concepts when it comes to the trials in life:
1. Trials are necessary for character building, for helping us cultivate qualities like courage, patience, maturity, etc (and alternatively, to expose bad people for what they truly are),
2. Trials also expiate sins, and the hadith examples on the topic are legion (a keyword search generated this list)
3. For whatever trials and suffering we may face in this world, our patience in the face of these trials would be compensated for in the afterlife many times over.
The question is: if trial is so important and beneficial for the spiritual life of a Muslim, why should we not try to actively seek out trials? What is stopping us from inflicting pain on ourselves, leading unnecessarily harsh lives, not taking medicine when sick, and so on? Especially given the lucrative promise of rewards in the next life, people should be praying to God for calamities to strike them, no? And yet Islam explicitly asks us not to do any of the above. The believer is asked to pray for ease, not difficulty; for felicity in both this life and the next, not only in the next in expense of the present. The Prophetic practice was always to choose the easy route among otherwise equally beneficial options.
I know the question is easy to answer, and indeed Muslim scholars have written about calamities and the appropriate attitude to have about them. In her essay in Howard-Snyder edited The Evidential Problem of Evil, Eleonore Stump gave a really intuitive and illuminating response.
The basic idea is this. We know things like working out and medicine are good for us. However, too much working out leads to physical problems. But on what basis shall we decide what amount of working out is good and beneficial, and what amount is harmful? On the basis of expert prescription. Similarly, trials are indeed good for us, but too much of it is obviously bad, since too much of it may damage our body and spirit, and make us unable to fulfill duties owed to God and the people in the long term. Who decides exactly what amount of trial is good and bad?
This is where the concept of Divine prescription of trials comes into play. According to the Divine instructions regards trials and suffering (as found in Islamic scriptures)- we shouldn't ask for trials, rather, whenever we fall into trials, or see others suffering, we should always work to alleviate it. We should always pray for ease and not suffering. That's the Divine prescription. In spite of all of this, however, trials would inevitably afflict us, and we would not be able to reduce much of it even if we tried. The Divinely prescribed amount of trials is just the amount that is unavoidable in this sense. Whatever residue of trials remain in our lives after we have tried our best to get rid of it- is just the right amount of trials for us to have. If we go looking for more than this, we may end up pulling a spiritual muscle.
In short, although trial is good for us, it's only good for us in a certain amount, to a certain extent. The way to know that Goldilocks' amount is to rely on Divine prescription, which is to try and avert as much suffering as we can, but patiently try and endure whatever amount is inevitable and irreducible.
This view of trials strike me as very empowering. On one hand, it teaches us explicitly not to suffer in silence. To help ourselves and our fellow creatures whenever the opportunity presents itself. This is in tune with our "humanitarian" values and intuitions. On the other hand, it teaches us to not lose hope in the face of inevitable suffering, for it would be entirely positive and beneficial for us in the long run.
Strive for ease as much as you can, but think positively of whatever suffering you can't escape. Take it in stride and praise God. That's the recipe for a happy life (and afterlife).