One of the points of the book of Job is that his friends, after a period of exemplary silence, got it wrong when they began to defend God in the face of Job the innocent sufferer’s complaints.
Despite all the bad things Job says about God, at the end of the day, God justifies Job, not Job’s friends, and instructs Job to pray for his friends, because they, not he, risk God’s displeasure (Job 42:7-9).
Defense of man before God (anthropodicy), not defense of God before man (theodicy), is appropriate when undeserved suffering occurs. Job’s friends should have defended Job against God rather than God against Job.
The theodicy of Job’s friends does not do justice to the status of the sufferer in God’s sight. The right response to undeserved suffering is to vindicate the sufferer even if that means calling God’s actions, or inaction, into question. There is plenty of biblical precedent for this. It’s called standing in the breach or intercession. The Hebrew Bible includes a number of examples. A few off the top of my head: Gen 18:22-30; Ezek 22:30 (on the need for intercession); Isa 63:15-64:12; Psalm 44.
An innocent sufferer’s non-justification of God is perfectly acceptable in the Bible. Psalms 13, 22, and 88 may serve as examples.
Anyone who plans to deal with the subject on the academic level needs to take a look at Antti Laato and Johannes C. De Moor (eds.), Theodicy in the World of the Bible. (Leiden: Brill, 2003). Pp. liv+830. Here is a helpful review. Despite its girth, the volume only scratches the surface of a vast subject matter.