A controversial book on this matter was titled When Bad Things Happen to Good People. A common objection to religion is, How can anybody believe in God in light of all of the suffering that we see and experience in this world?
John Stuart Mill raised this classic objection against the Christian faith: If God is omnipotent and allows all this suffering, then he is not benevolent, he is not a kindhearted God, he is not loving. And if he's loving to the whole world and allows all this suffering, then he's certainly not omnipotent. And given the fact of evil, or the fact of suffering, we can never conclude that God is both omnipotent and benevolent. As brilliant as John Stuart Mill is, I have to demur at that point and look at what the Scriptures say about these things.
Keep in mind that from a biblical perspective, suffering is intrinsically related to the fallenness of this world. There was no suffering prior to sin. I interpret Scripture to say that suffering in this world is part of the complex of God's judgment on the world. You are asking, How can a righteous judge allow a criminal to suffer? How can a just judge allow a violent offender to be punished? The question we should ask is, How can a just judge not allow punishment for those who have committed acts of violence or crimes of any sort? Behind that question always stands the holiness of God and his perfect righteousness. Our understanding of God is rooted and grounded in the teaching of Scripture that he is the just Judge. The Judge of all of the earth always does right.
In the ninth chapter of John, the Pharisees say to Jesus, "Why was this man born blind? Was it because of his sin or the sins of his parents?" Jesus said, "Neither one." We can't come to the conclusion that an individual's suffering in this world is in direct proportion to that individual's sin. That was what Job's friends did when they came to him and tormented him by saying, "Boy, Job, you're really suffering a lot. This must be an indication that you're the most miserable sinner of all." But the Bible says that we can't use such a formula. The fact is, if there were no sin in the world, there would be no suffering. God allows suffering as part of his judgment, but he also uses it for our redemption—to shape our character and build up our faith.