The problem of evil is one of those philosophical arguments that lands differently when you first read it in a textbook versus when you've watched someone you love suffer slowly and without purpose. The abstract argument is clean. The existential weight of it is something else.
The argument in its classic form goes back at least to Epicurus (341–270 BCE), later reconstructed by David Hume:
Is God willing to prevent evil but not able? Then he is not omnipotent. Is he able but not willing? Then he is malevolent. Is he both able and willing? Then whence cometh evil? Is he neither able nor willing? Then why call him God?
This is the logical problem of evil: the claim that the existence of an omnipotent, omniscient, omnibenevolent God is logically incompatible with the existence of evil and suffering. If God could prevent all evil (omnipotence), knows about all evil (omniscience), and wants to prevent all evil (omnibenevolence), then no evil should exist. Evil exists. Therefore such a God does not.
In 1710, Gottfried Wilhelm Leibniz published Theodicy, a word he effectively coined, meaning the justification of God in the face of evil. His answer: this world, despite appearances, is the best of all possible worlds. God, being omniscient, surveyed all possible worlds and chose the one with the greatest overall good. The evils that exist are necessary features of the best package available, they could not be removed without making things worse overall.
Voltaire found this answer so obscenely inadequate that he wrote Candide (1759) partly as a satirical assault on it. Pangloss, Candide's relentlessly optimistic tutor, cheerfully explains that the Lisbon earthquake (1755, which killed between 30,000 and 40,000 people) is all for the best in the best of all possible worlds. The joke is devastating and intentional. Whatever the abstract merits of Leibniz's theodicy, it seems to fail at the most basic level: it cannot be said to someone watching their child die of cancer without being a kind of moral obscenity.
And yet Leibniz's argument is not as simple as Voltaire makes it. The claim is not that this specific event is good. It's that any world that permitted human freedom, natural causation, and the development of virtue through adversity would necessarily contain some evil, and that such a world might be better, all things considered, than a sterile world of perfect painless happiness. The best possible world need not be the world with the least suffering, it might be the world with the greatest total value, and some forms of value (courage, compassion, solidarity) can only develop in a world that contains suffering to respond to.
Quick reflection
Leibniz says this is the best of all possible worlds — that God chose it from all conceivable alternatives. Can you construct a world slightly better than the actual one — with, say, one fewer terminal childhood cancer diagnosis — without it being worse in any respect? If you can, what does that do to Leibniz's theodicy?