I'm amazed at the attempt to interpret the Book of Job to fit modern controversies that largely have nothing to do with it. So let me just lay out what I think the Book of Job is actually arguing for.
There was a common thought that because God rewards good behavior and punishes evil behavior (you see this throughout the law and the prophets) that this means that God brings adversity only to those who sin against Him. This isn't what the law and prophets taught. It's a non sequitur based upon a false reading of those Scriptures.
Hence, we get books like Ecclesiastes, Daniel, and Job to tell us that this is a misreading. Daniel lets us know that the ultimate working out of God's rewards and punishments is at the resurrection, not necessarily in this life. Ecclesiastes tells us to look to the judgment as well, rather than this life as finding fulfillment and hope. Likewise, Job exists to tell us that God brings adversity even upon the righteous.
There exists more than one message, of course, in the book. Satan challenges God that Job only follows Him because God has brought good things into his life. But one of the main messages of the book is that man ought to follow God even through adversity because God is worthy as the Creator and Sustainer of the universe to be trusted and followed no matter what.
But another message, perhaps its main message, is that adversity in one's life is not necessarily caused by sin, nor is prosperity in one's life necessarily caused by righteousness. Job's friends represent those who have misinterpreted the law and prophets as saying otherwise. They think that if Job is suffering so badly, it can only mean that God has turned against him; and if God has turned against him, it can only mean that Job has sinned against God.
If Job was righteous, God is just and would not deliver his life into such devastation and tragedy. Job himself wants his day in court with God, and argues that God has afflicted him without cause. Hence, he calls God's justice into question.
That latter point is important, because many think that because Job does not "curse" God, this means he doesn't question His just nature. Instead, Job realizes that God's power makes him helpless against God's decisions, and so, God can do what he pleases to him, but there is no reason for Him to do so.
The epilogue corrects Job on this, not by telling us that God didn't do these things, or by saying that God is just, but instead, that God does have the right by power to do these things, but that He also understands every working in the cosmos and has reasons for them, even though these are often not discernible to finite men.
Hence, the search to find some reason that God has turned against Him, whether the reason thought up by his "friends" (i.e., that Job must be impure in some possible way) or by himself (that God must be unjustly persecuting him for no reason simply because He can) are misguided attempts to understand the necessity of God's decisions in some people's lives.
That's not the message we want because that's not a message we can control. We can't do anything about it. We want to have control and make the things we want to happen happen. But Job tells us that we really don't have the control we think we do. We cannot secure a prosperous life by virtue of our disposition to God either way. The other two books I mentioned, Ecclesiastes and Daniel, tell us that our disposition toward God does affect our judgment and resurrection, but it does not in this life, precisely, because of what we are told by these books--namely, that both righteous and unrighteous people get the same sorts of things in this life.
Of course, we are given more reasons why this is in the New Testament: i.e., they conform us to the image of Christ and complete God's creation in us from being chaotic agents into becoming agents of life. But the Book of Job is at the foundation of all of that theology.
It does not exist to comment on whether humans are totally depraved, or give us reasons why God brings tragedy into our lives. There is no reason given. It exists to humble us before God and to seek God for His worthiness of being sought, even when He takes away the immediate, visible incentives for following Him.