A deep insight and analogy by Ibn al-Qayyim on "The Problem of Evil"
Ibn Qayim states, "…the father, who is compassionate towards his son and knowing what is good for him, sees that some blood has to be removed from his son for his own good, even though his son will incur severe pain by cutting the skin and cutting the veins. If the father knows that the cure for his son lies in cutting off one of his limbs, he does so, and does this all of this out of compassion and mercy to his son. If he sees that it is better for his son to withhold something from him, he withholds it and is not lavish towards him, because he knows that this causes his corruption and destruction. So the father often withholds from his son what his son desires for his own good and to protect him, not out of miserliness towards him.
So, if the wisest of all judges, the Most Merciful, the Most Knowledgeable, who is more merciful towards His servants than they are to themselves or their parents are to them, sends down upon them that which they dislike, then it is better for them than Him not sending it upon them at all; rather, it is a benevolence and kindness to them. For if they were left to choose for themselves, they would be incapable of knowing, intending or doing that which benefits them. But He - how perfect He is - has taken charge of managing their affairs according to His knowledge, wisdom and mercy, whether they like or dislike it."
al-Fawaaid - (174)