According to the Merriam-Webster Dictionary, theodicy is "defense of God's goodness and omnipotence in view of the existence of evil." The book of Job and the book of Lamentations approach theodicy in vastly different ways.
In the book of Job, the struggle between good and evil is pictured as a game or wager between God and Satan. In the first chapter, Satan comes to appear before God, and God brags about how Job is "a perfect and an upright man, one that feareth God, and escheweth evil." Satan replies that Job is close to God because Job is rich, and God blesses everything he has, but then he taunts God and says that if God takes away everything that Job has, "he will curse thee to thy face."
God gives Satan permission to take everything from Job but not to touch Job himself. Job loses all his material possessions, including his sons and his daughters, but Job still falls down and worships God. In chapter 2, God again brags about Job to Satan, who requests permission to afflict Job's flesh. God acquiesces but demands that Satan should save Job's life. After Satan gives Job terrible sickness and pain, Job then wishes that he had never been born. When his friends come to mourn with him, they try to persuade him to give glory to God, but Job is adamant that he has done nothing wrong to merit such treatment.
Job and his counselors are not able to resolve the dilemma of why such evil has come upon Job. Finally, in chapters 38–42, God takes care of the theodicy issue himself by speaking directly with Job "out of the whirlwind." Basically, he castigates Job for his lack of faith by asking Job if Job can do everything that God does in creating and maintaining the Earth. For several wonderfully poetic chapters, God reminds Job of all the miraculous things that he does to keep the universe running, and he asks Job, "Wilt thou condemn me, that thou mayest be righteous?" Job eventually repents, and God restores to Job "twice as much as he had before." We see, then, that in the book of Job, God defends his own goodness and omnipotence and insists that humankind has no right to self-righteously judge the issue of the existence of evil.
The book of Lamentations is much shorter. Basically, it consists of a prayer by the prophet Jeremiah to God after the destruction of Jerusalem by the Babylonians. He admits that Jerusalem has been destroyed, and the Jews have gone into captivity because of their sins. "For the Lord hath afflicted her (Jerusalem) for the multitude of her transgressions." Jeremiah touches on the concept of theodicy by making it clear that the Jewish people deserved this punishment. God did not want to do it, and when the Jews repent and return to him, he will have mercy on them.
For the Lord will not cast off forever: but though he cause grief, yet will he have compassion according to the multitudes of his mercies. For he doth not afflict willingly nor grieve the children of men.