The long exchange between God and Job could simply be summarized with the statement, "You are God, and I am not." This may not seem fair from our perspective, but getting back to the Apostle Paul's statement in Romans chapter 8, that in all things God works for the good of those who love him, here are the closing words of the book of Job, chapter 42, verses 10-16:
“When Job prayed for his friends, the Lord restored his fortunes. In fact, the Lord gave him twice as much as before! Then all his brothers, sisters, and former friends came and feasted with him in his home. And they consoled him and comforted him because of all the trials the Lord had brought against him. And each of them brought him a gift of money and a gold ring. So the Lord blessed Job in the second half of his life even more than in the beginning. For now he had 14,000 sheep, 6,000 camels, 1,000 teams of oxen, and 1,000 female donkeys. He also gave Job seven more sons and three more daughters. He named his first daughter Jemimah, the second Keziah, and the third Keren-happuch. In all the land no women were as lovely as the daughters of Job. And their father put them into his will along with their brothers. Job lived 140 years after that, living to see four generations of his children and grandchildren. Then he died, an old man who had lived a long, full life. (New Living Translation)
God had made a point and then greater good resulted.