John Frame's Systematic Theology, chapter 14
If God is all powerful, He can prevent evil.
If God is good, He wants to prevent evil.
Since evil exists, God is either not all powerful or not good.
This is the problem of evil.
The Bible gives a direct answer to why there is natural evil in the world (earthquakes, floods, etc.) in Romans 8:19-22: it is because of the entrance of sin. Moral evil came first, and natural evil is one result of it (Gen 3:17-19). "God has ordained that the universe resist its human ruler until that ruler stops resisting God."
Since God is sovereign, we can't say He is too weak to prevent evil. We also know He doesn't take pleasure in evil and that His ways are just.
There are 3 ways to answer the problem:
1. The nature of evil
2. How evil is "good."
3. God's responsibility for evil
1. The nature of evil
One theory is that evil is the lack or privation of being good. Created-good beings tend toward evil and non-being, and our created-good will falls into evil. But why can't God prevent such tendency if He is good? Is there a tendency toward imperfection in the "nature" of created things? Not necessarily. And why must we say evil is lack of good and nothing on its own? Good came before evil, but we don't need to say that evil is nonbeing. The Bible doesn't use these philosophical categories about sin. Most important, this doesn't get rid of the problem. A doughnut maker is still responsible for the hole in the doughnut; God decided what to leave out of His creation, if evil is something "left out."
2. Evil contributes to a greater good.
Look at the bigger picture. Surgery brings pain, but heals in the long run. God has a greater purpose in permitting evil than preventing it. Various greater purposes are suggested: order (God can't suspend gravity for everyone who falls down stairs, we wouldn't know what to expect); maturity (we need discipline and hard knocks to grow up); free will (God wants to let us be free to choose good or evil); revealing more good (compassion and patience would not exist without evil). God made an orderly world at the beginning with no evil, so that isn't needed. We'll deal with free will later. The second option of maturity and God's purpose is the best solution. "You meant it for evil, but God meant it for good" Genesis 50:20. "All things work together for good for those who love God" Romans 8:28. The greater good is not our comfort or pleasure, but God's glory. The cross is the greatest example of God bringing good out of evil. So this answer is legit. One lingering question though: how is this not an "end justifies the means" argument? How is it right for God to use morally questionable ways to get to a good purpose? Frame's answer to this is unsatisfactory, simply asserting that it may not be questionable when God does it. I land on 2 Corinthians 4:17: "our light affliction, which is but for a moment, is working for us a far more exceeding and eternal weight of glory."
3. God's Agency and evil
In some sense God brings evil things to pass, but is not the author of it. He ordains it but doesn't cause it. The Reformed confessions all affirm this distinction. Calling God the more remote cause while Satan, thieves and wind are closer causes of Job's woes may help a little, but you can't totally absolve God of responsibility by this. Saying God permits evil doesn't help much, because "God's permission is an efficacious permission." It indicates God ordains sin reluctantly while also hating it. But permission is a kind of ordination. A better answer may lie in seeing God as author of a play. Shakespeare has MacBeth kill Duncan, but Shakespeare should not be punished for murder. "God is not subject to the ignorant evaluations of his creatures" as we see at the end of Job. When Romans 9:19-21 comes to the problem of evil, the answer is that God is above us, not at all that He allows us free will.
So God brings a greater good out of allowing evil for now, and He ordains it as an author is not morally responsible for the sin of his character. We cannot accuse God as He is the potter, the Creator, and we are the clay, His creatures.