The book of Job is very difficult to understand. The author seems to have different messages at different parts of the story. One can study Job for many years but usually can't resolve the contradictions.
Perhaps, the text is actually a parody, where Job imitates Satan attacking God to enlighten his friends
Do they get it? Apparently not.
Today we see God differently then people did during Job's tenure. Many, many diseases and misfortunes are attributed to science and fortune. God is a less imposing factor. Thus, we are able to interpret Job in a different light. The author of Job was a genius and somehow his thinking made it into the Bible even though it doesn't seem to fit with other texts. If God exists, He wanted to preserve the author's point of view.