A Muslim has to believe in the Wisdom of Almighty Allah for creating everything in this life. Almighty Allah says in the Qur’an, (What! Did you then think that We had created you in vain and that you shall not be returned to Us?) (Al-Mu’minun 23:115)
Thus, there is divine wisdom behind everything that is done by Almighty Allah. He does not create absolute evil. He creates a child who experiences illness or death for the sake of his parents; if they are patient and thankful to Almighty Allah, He will reward them in the Hereafter. This can be even for the sake of the child himself as Almighty Allah will also compensate him for the pain he endures. The same applies for the creation of some people who are insane. There is great wisdom behind this; when sane people see them, they know the benefit of the mind that Almighty Allah granted them, so they thank Him for that. It is also a trial for the relatives of insane people and even for the community; how they will treat them.
Therefore, we have to know that this life is a test. Almighty Allah creates diseases, death, insanity and all other things that we may see as evils, but it is a trial from Almighty Allah to test our faith. Almighty Allah says in the Qur’an, (Do men think that they will be left alone on saying, “We believe”, and that they will not be tested?) (Al-`Ankabut 29:2)
Sheikh Salim `Abdus-Salam Ash-Shaykhi, da`i and member of the European Council for Fatwa and Research, states: We have to accept all the decisions from Almighty Allah as good and for our best interest, whether they appear positive or negative from our perspective. We do not comprehend the wisdom of Almighty Allah, but we believe in His wisdom, and that if we were to be shown this wisdom, we would have thanked Him for doing so.
Usually, people think that everything is related to this life, but that is totally wrong; it is the Hereafter that is permanent. The bottom line is when we stand in front of Almighty Allah and see everything in the right perspective, we will thank Him for doing what we thought was bad for us.