Job 42:1-6 (NIV)
Then Job replied to the Lord: "I know that you can do all things; no plan of yours can be thwarted. You asked, 'Who is this that obscures my counsel without knowledge?' Surely I spoke of things I did not understand, things too wonderful for me to know. You said, 'Listen now, and I will speak; I will question you, and you shall answer me.'
My ears had heard of you but now my eyes have seen you. Therefore I despise myself and repent in dust and ashes.
God finally has Job where he wants him. The righteously indignant young man Elihu had pointed out that Job's three friends were wrong. Their idea that great suffering implies great wickedness was wrong. God had already declared Job righteous. Elihu said Job was wrong too. Job was righteous but not perfect. There was a heretofore unseen sediment of pride in his life that had been stirred up by his affliction. Job had said wrong things about God maintaining his innocence at the expense of God's justice. Elihu proclaimed to Job that suffering for the righteous was not punishment from an angry God but rather refinement from a loving God. Suffering for Job was like the pain of the surgeon's scalpel. Finally God demonstrates his majesty and sovereignty to Job. God's might has a purpose to bring down the proud and to exalt the humble--all for His glory.
Now Job admits his lack of understanding. All of his remaining pride is removed when he sees God as He truly is. His only possible response is repentance. Now, for the rest of the story...
Job 42:7-8a,10 (NKJV)
And so it was, after the Lord had spoken these words to Job, that the Lord said to Eliphaz the Temanite, "My wrath is aroused against you and your two friends, for you have not spoken of Me what is right, as My servant Job has.
Now therefore, take for yourselves seven bulls and seven rams, go to My servant Job, and offer up for yourselves a burnt offering; and My servant Job shall pray for you.
And the Lord restored Job's losses when he prayed for his friends. Indeed the Lord gave Job twice as much as he had before.