It is easy for us to read Job's story and critique him at certain points. But we need to keep in mind that Job never read the Book of Job. He didn't know it would turn out well in the end. He didn't know about the conversations between God and Satan. He didn't know why everything was happening. All he knew was that one day, it all was going beautifully, and the next day, the bottom dropped out with no real explanation that he could see. Yet Job persevered in his faith and integrity.
We are told in James 5:11, "We give great honor to those who endure under suffering. For instance, you know about Job, a man of great endurance. You can see how the Lord was kind to him at the end, for the Lord is full of tenderness and mercy." God's plan finally ended in good, but Job could not see that midstream.
There are things about life that we don't understand. God can bring good out of bad. It doesn't mean that bad becomes good, because bad is bad. But it does mean that God can bring good despite bad, and our tribulations can bring forth good things. As Hebrews 12:11 says, "No discipline is enjoyable while it is happening—it's painful! But afterward there will be a peaceful harvest of right living for those who are trained in this way."
Before disciplining a child, a parent sometimes will say, "This will hurt me more than it will hurt you." Meanwhile, the child is thinking, Yeah, right!
That is how we feel when we are being disciplined or are going through hardship. It hurts. But it also brings forth something good.
God can take the greatest of tragedies and turn them into the greatest of victories.