So Eliphaz the Temanite and Bildad the Shuhite and Zophar the Naamathite went and did what the LORD had told them, and the LORD accepted Job's prayer.
And the LORD restored the fortunes of Job, when he had prayed for his friends. And the LORD gave Job twice as much as he had before.
The "happy" ending of the story of Job comes first with Job's own repentance (Job 42:1-6). Job realizes that he has spoken "without knowledge" and now that he has heard from God, he repents of his demands for explanation of his losses. That's good, because The Lord is never compelled to give him that explanation in the least. The reality is that it literally did not matter about "why" things happened at the moment that he heard from God in the storm. The reality of the fierce holy power and the sovereign love of God threw all Job's questions down. Job repented of ever wanting them answered in the first place. God Himself was all that Job needed at the end of the matter.
After repentance came restoration. And The Lord brought two levels of restoration. First, there was restoration of relationships. The very first matter of business was for Job's friends to repent as well. Job had led the way, and now Eliphaz, Bildad, and Zophar had humble business to do with God. The Lord commanded them to repent by having Job serve as a priest for their sacrifices. They did so, and upon Job's prayer for them, The Lord accepted their repentance. So in the end Job got his friends back through mutual worship and obedience. And God ensured that the way in which that happened vindicated Job and rebuked the insolence of his friends.
There was also restoration of fortune. Job became the recipient of supernatural blessings, just like God had sovereignly brought the bad circumstances of disaster upon him. His fortunes are now reversed and restored to twice his former estate. Over the rest of his lifetime, Job is blessed with seven sons and three daughters. He lives out his days blessed by God to the ripe old age of 140 (twice the normal lifespan) and the story ends in God's sovereign blessing on an exceptional servant who passed the test of suffering.