In the chapter that we read of The Problem of Pain, Human Pain, C.S. Lewis addresses the issue of how a purely good God that is omnipotent could allow pain to happen. Lewis explains that it is us, not God, that have created pain. He says that God did not create the whip, we did.
God created Earth in perfect harmony. Evil did not come into the world until Adam and Eve brought it here. God did create everything, so evil had to come from some place. Unless evil is not something that can be made. Evil is the absence of good, just as darkness is the absence of light.
Some people argue that it does not matter that God did not create evil, because he still allows evil to happen. God does not simply allow evil to happen though. God gave people free will; we all have the choice to follow God or not to follow God. The gift of free will is a good gift and we have abused it. We have allowed evil into our hearts. If God were to purge the world of evil he would have to split the soul of every person into two. The battle between good and evil is not simply between those who are good and those who are evil, it is a constant battle that we fight every day in the depths of our soul. It is only through the power of Christ that we can be redeemed despite the evil in our lives.