Then Job answered:
“Indeed I know that this is so;
but how can a mortal be just before God?
If one wished to contend with him,
one could not answer him once in a thousand.
He is wise in heart, and mighty in strength
—who has resisted him, and succeeded?
It seems here that Job is no longer clinging to his earlier idea that he is indeed righteous and pure. Instead, he is admitting that his friend is correct: he is sinful and has done wrong things. But, he also points out that God is not a God that would insist that every single little sin and wrong-doing be brought to mind and confessed before relating favorably towards someone.
Job is saying that people are too sinful for God to structure the world in such a way that the righteous are related to in one way and the wicked in another, because everyone belongs fully in that latter camp. There can only be two sets of rules if there are two teams playing the game.
He is in effect saying what Paul says in Romans 3, that all people have sinned and fallen short of the glory of God, therefore there is no distinction among people. Ironically, then, Job’s defense here is not necessarily the he is righteous, but rather that he is far too messed up for his friends’ version of reality to be right.
Also of note, the rest of this chapter is more or less Job proclaiming the very things that God uses to rebuke him at the end of the book. Job really does seem to know this stuff.