Theodicy is the study of the problem of evil in the world. The issue is raised in light of the sovereignty of God. How could a holy and loving God who is in control of all things allow evil to exist? The answer has been debated for as long as the church has existed. We still do not have a definitive answer, and the Bible does not seek to justify God's actions.
It is clear that God is sovereign, that He has willed the existence of both good and evil, and that all of this is for His own glory. Prov. 16:4 says, "The LORD works out everything for his own ends--even the wicked for a day of disaster"; Isaiah 45:7 says, "I form the light and create darkness, I bring prosperity and create disaster; I, the LORD, do all these things."