Wa `alaykum As-Salamu waRahmatullahi wa Barakatuh.
In the Name of Allah, Most Gracious, Most Merciful.
All praise and thanks are due to Allah, and peace and blessings be upon His Messenger.
This question often leads to an argument for the non-existence of God like the following:
1- God exists and is All-powerful, All-knowing and wholly Good.
2- Evil exists.
3- As the above two are logically incompatible, they cannot both be true. And it is obvious that evil exists; so God does not exist.
Islam teaches that God is All-Powerful, but it does not mean that He does things that contradict logic or do not befit His character. For instance, He does not make a circle a square, while keeping it a circle and a square at the same time.
It is also an Islamic teaching about God that He is Perfect and so He does not suffer or die, because that is against His nature.
The second question involved in the above argument is: If He is Good, why does He allow evil?
The answer is that a good God may allow evil if He has a good reason. And we need not know God’s reasons for allowing evil, because God says in the Quran that we are given only very little knowledge:
Therefore, it would be enough if we know of a possible reason for God to allow evil to exist. And from the Quran we can understand that God has given humans free will, in order to test them to prove who is better in good deeds.
"Every soul shall have a taste of death: and We test you by evil and by good by way of trial; to Us must ye return". (21:35)
One consequence of freedom is that humans may choose evil instead of good. If they are forcefully prevented from choosing evil, there won’t be any freedom. That is to say, God cannot have free beings whom He forces to choose only good; because that would involve a logical impossibility.
As intelligent beings we know that most things that make life worth living require that we have free will. Moral responsibility, a sense of individual achievement, and satisfactory personal relationships are a few valuable things that cannot exist without freedom of choice.
Why Natural Disasters?
But one may ask why natural evils like earthquakes are permitted, where free will plays no part.
The answer is in the cause and effect nexus which is a part of nature. We know that our actions are to a great extent motivated by the expectation of realizing desirable results. This is possible only if our actions actually lead to results. Then our actions become meaningful, and we can hopefully engage in good works.
We know fire is useful because it burns and helps us cook our food; but the same burning quality of fire can burn down homes. That is to say, the very things that are useful for us can inevitably cause damage too. Now can we completely dispense with fire as it has a destructive side?
From the Islamic point of view, evil is like one of the twins, the other being good, as good on earth is ironically linked to evil. Because, good in this world cannot exist without bad, as they are two sides of the same coin, and both are relative concepts.
For instance, to rescue a drowning man is good work; but this is possible only when someone is drowning, which is a bad thing. That is to say, we have a chance to do good work only when there is a need, which in itself is “evil”, or at any rate not “good”.
We replace that evil, or the absence of good, with good. The imperfections and shortcomings of this world provide ample opportunities for us to make creative efforts for improvement, and this makes our lives and work meaningful.
It appears that the forces of good and evil work in opposite directions; but in the final analysis, their work may be seen as a covert cooperation to fulfill the divine plan. And we know, evil cannot be without God’s willing it to exist; and if so, evil has a role to play.
Necessary for Spiritual Growth?
In short, both good and evil are equally necessary for the spiritual development of man. For the spirit to grow, it has to overcome evil and do good.
God says in the Quran what means:
"Nor can goodness and evil be equal. Repel evil with what is better…" (41:34-5)
That is to say, we must counter evil with good. But to do this, immense patience is necessary. As for believers, good does not spoil them, nor does evil make them desperate.
We may say that a believer should have two kinds of patience: one kind of patience in the face of moral evil; and another kind of patience in the face of natural evil. Both kinds are required for spiritual development.
An example of moral evil is the insult a believer suffers from an arrogant person. Here the believer controls his anger with patience, and he is successful in the test.
One of natural evils is a flood in which many people, including children, suffer. Believers in this context do not curse God, because they take it as a test of their faith. So they go out to help the victims in whatever way they can.
If they themselves are victims, they are patient and seek forgiveness from God for their own failings and pray for protection. And in this act, they draw near to Allah and are successful in that test.
Prophet Muhammad once said:
"Wondrous are the believer’s affairs. For him there is good in all his affairs, and this is so only for the believer. When something pleasing happens to him, he is grateful, and that is good for him; and when something displeasing happens to him, he is patient, and that is good for him.” (Muslim)
God says in the Quran what means:
"Seek help in patience and prayer; It is indeed hard, except to those who bring a lowly spirit…". (2:45)
Believers have the conviction that all things and events are under the control of God and so they never lose hope. They trust in the eternal benevolence and mercy of God, who says in the Quran:
"On no soul does God place a burden greater than it can bear". (2:286)
"And My mercy extends to all things". (7:156)
As God’s mercy is all-pervading, it fulfills the smallest need of the lowliest creature in the most unexpected ways.
Almighty Allah knows best.