In the end he is vindicated by God. What he is really famous for is not his patience but his righteousness (see Ezekiel 14).
And how does he remain in the right with God? One statement sums up Job’s attitude: “Though he slay me, yet will I hope in him;” (Job 13.15). He trusts God. He has such confidence in God that he wants to dialogue directly with God about his troubles (which he rightly attributes to God’s doing).
Job is a great example of what Habakkuk said, “the righteous live by their faith.” (Hab 2.4). Although not the greatest example: that prize goes to Jesus, the one who lived faithfully by faith in God.
And that is the answer to the repeated question in Job. How can a person be in the right with God? By trusting God and faithfully depending on him. And what if the person knows themselves to be far from righteous? Then they can only trust God’s promise to provide them with a righteousness that is not their own, that they don’t deserve and cannot produce.
Dale