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?
Epicurus
God gave us free will.
It means that we have capacity to do good or evil.
If God prevent us to do something, he block our free will and freedom.
Without our freedom we will be just like robots and God don't want it.
So, God have no choice but to allow both good and evil in this world, so that people can learn from their suffering and return to him, like in the story of ''Prodigal son'' in the Bible.