If someone asks how is it that Allah wants something yet He dislikes it? How one can understand such concept?
We all know that there are many drug prescriptions disliked and hated for their smell and taste, yet when it is known that there is a cure in them, we take them and we love them for that! Traveling a long and difficult journey to achieve something desired and loved is another example. If it is known that a surgical removal of a diseased part of the body would save the rest of it, it is disliked and hated from one side and liked from another. So, it is not contradictory to have love and hate combined in addressing one matter. This is true with the created being, so what about Allah the Creator Whom there is nothing hidden from Him and to Whom belongs the Perfect Wisdom? He, the Exalted, hates a matter in itself and, on the other hand, wants it because of its link to yet another matter, or because it is a means that leads to something He loves. In all of His actions, Allah has the Perfect Wisdom. We may recognize part of His Wisdom, or the general aspects of it, but not its complete details. One vivid case about this subject, is the Creation of Iblees, who is the sponsor of every corruption and evil in this world. He is hated from one side, yet Allah wanted his creation because he is a means for many beloved things to Allah, and that there is great wisdom behind his creation.
Similarly, there is wisdom behind the creation of calamities, sufferings, hardships, etc. that speak about the Favors of Allah, His Justice, and His Mercy. Some of this wisdom includes:
*Tests for the believers.
*Training and strengthening of the believer’s faith.
*An evidence for the weakness of man and his need for his Rabb, and that he has no success unless he humbles himself to his Creator.
*A way to expiate sins and an elevation to higher degrees in the Sight of Allah.
The Prophet ( sallallahu `alayhi wa sallam) said: “There is nothing (in the form of trouble) that touches the believer, even the pricking of a thorn, except that Allah decrees a good for him or effaces one of his sins because of that.” 
*It is a means for receiving reward for both, the ill Muslim and the Muslim doctor in charge.
*Witnessing the occurrence of favors and blessings after calamities and hardships, has more profound effects and generates a meaningful and proper appreciation of Allah’s Power, Wisdom, Mercy and Justice. He, the Exalted, is to be Praised on all of His Decrees.
*An appreciation for good health and the well-being of one’s self.
*A reminder about what is more devastating, Hell. A lesson to remember and a build up of eagerness for Paradise.
*...And many more wisdoms of which we may know or we may not know. We cannot say: How did Allah allow this and prevent that? Nor how did He create this, and how come He did not create that? …Nothing escapes His Ability, and nothing occurs in His Kingdom except that He had willed it; He owes us nothing; if He gives, then its His Favor and if He prevents, then it is His Justice.
“If Allah (swt) puts a person under certain tests and trials and the person recognizes that He must resort to Allah alone seeking His help, then this is a good sign for him; the trials turn to purification and mercy. If, on the other hand, he rejects, complains, and turns away from Allah and resorts to human beings like him, then this is a bad sign for him; the trials turn to punishment and misery upon him”.
1. See The Belief in Al-Qadaa' wal Qadar by Muhammad bin Ibraheem Al-Hamad, PP. 85-89. Published by Daar Ibn Khuzaymah, Riyadh, K.S.A 1415AH/1994.
2. Saheeh Muslim, V. 4, Hadeeth # 6241.
3. Summarized from lbn Qayyim’s Tareequl Hijratayen, FN # 103, P. 259.