This is not a perfect universe but there are many others. Whatever problem, affliction, disease you get is also serving some other purpose and not only because of cause and effect.

Recitation of the Holy Scripture.
Whatever is in the heavens and whatever is on the earth glorify God, and He is the All Mighty, the AllWise.
To Him belongs the dominion of the heavens and the earth, He gives life and causes death, and He has power over everything.
He is the First and the Last, the visible and the invisible, the Outer and the Inner, and He is the AllKnower of everything
He is the One Who created the heavens and the earth in six days and then established Himself above the Throne. He knows what penetrates into the earth and what comes forth from it, what descends from the heaven and what ascends therein; and He is with you wherever you are. And God is AllSeer of what you do.
To Him belongs the dominion of the heavens and the earth, and to God return and referred all the matters.
He merges the night into the day and merges the day into the night, and He is AllKnower of what is in the breasts.
To Him is referred the knowledge of the Hour. And fruits do not emerge from its coverings nor does any female conceive or give birth except by His knowledge. And the Day when He will call out to them, “Where are My partners?” They will say, “We announce to You, that none of us bears witness to it.
And those whom they were invoking before will be lost from them, and they will be certain that they have no place of escape
Man does not get tired of asking for good, and if an evil touches him, then he gives up hope and despairs.
And verily, if We let him taste mercy from Us after an adversity has touched him, he will surely say, “This is due to my (merit), I do not think that the Hour will be established; and if I am returned to my Lord, indeed, I will have with Him the best.” But We will surely inform those who disbelieved about what they did and We will surely make them taste a severe punishment.
And when We bestow favor upon man, he turns away and distances himself; but when evil touches him, then he is full of lengthy supplications.
Have you considered: if this is from God and you rejected in it who would be more astray than one who is in extreme dissension?”
Soon We will show them Our Signs in the horizons and within themselves until it becomes clear to them that it is the truth. Is it not sufficient concerning your Lord that He is a Witness over all things?
Surely they are in doubt about the encounter with their Lord. Surely He comprehends everything.
On the Day you will see the believing men and the believing women, their light proceeding before them and on their right, (it will be said to them), “Glad tidings for you today gardens underneath which rivers flow, abiding therein forever. That is the great success.”
On the Day the hypocrite men and the hypocrite women will say to those who believed, “Wait for us so that we may acquire some of your light.” It will be said, “Go back, behind you and seek light. Whereupon a wall will be erected between them, in which is a gate; inside the gate is mercy, and on the outer side is the punishment.
Know that the life of this world is nothing but play and pastime, and pomp and boasting amongst yourselves and the desire to surpass each other in wealth and children, like the rain, the produce of which pleased the farmer, then dried so you see it yellow and then turned into dry trampled hay; and in the Hereafter is a severe punishment, and the forgiveness from God and His pleasure. And the life of this world is nothing but the enjoyment of delusion.
Race toward forgiveness from your Lord and a Garden whose width is like the width of the heavens and earth, prepared for those who believed in God and His messengers. That is the bounty of God which He gives to whom He wills, and God is the Possessor of Immense Grace.
No disaster strikes on the earth or within yourselves, but is in a Book before We bring it into existence. Indeed, that is easy for God.
So that you may not grieve over what has escaped you, nor exult at what He has given you. And God does not love any self deluded boaster.
End of Recitation of the Holy Scripture.
O Mankind no disaster, disease, affliction and calamity strikes on the earth or within yourselves, but is in a book before your Lord bring it into existence. And whatever misfortune affliction befalls you, it is because of what your hands have earned. And you cannot escape in the earth and you do not have, besides God, any protector or helper.
O mankind although your Lord has made this world a trial and this universe is not a perfect place even than its not only the material world and its cause and effects that are responsible for all the events, there is also something else. Let me here also respond to the question of skeptics when they say that if there is an intelligent creator, than that must be shown through His creation. They say the universe we see around ourselves is not perfect. As it took almost 15 billion years to arrive at this universe we see around us. Than most places in the universe, more than 99% would kill life instantly. They say