I don't think anyone is saying the trials of Job were the consequence of sin, but rather they helped to purge him. The crushing of Job brought out a lot of good, but also some bad. Job himself said that he didn't speak rightly. Not that he spoke wrong of God, but that he spoke without understanding that God is so far above him.
So even though Job was a great man he was still a man.
Did you know that in the book of Lamentations chapter 3 that there is a corresponding verse in Job for every one of the first eighteen verses?
Only the first seven verses are presented due to volume. If you want the rest I will provide them.
Lamentations 3:1 I am the man who has seen affliction by the rod of his wrath.
Job 19:8 He has also kindled his wrath against me, and he counts me to him as one of his enemies.
--------------------------------------------------------------------------------------------
Lamentations 3:2 He has led me, and brought me into darkness, but not into light.
Job 30:26 When I looked for good, then evil came to me: and when I waited for light, there came darkness.
--------------------------------------------------------------------------------------------
Lamentations 3:3 Surely against me He has turned His hand Repeatedly all the day.
Job 30:21 You have turned cruel to me; with the might of your hand you persecute me.
--------------------------------------------------------------------------------------------
Lamentations 3:4 My flesh and my skin has he made old; he has broken my bones.
Job 33:21 His flesh wastes away to nothing, and his bones, once hidden, now stick out.
--------------------------------------------------------------------------------------------
Lamentations 3:5 He has built against me, and compassed me with gall and travail.
Job 16:13 His archers compass me round about; He cleaveth my reins asunder, and doth not spare; He poureth out my gall upon the ground.
--------------------------------------------------------------------------------------------
Lamentations 3:6 He hath made me to dwell in dark places, as those that have been long dead.
Job 3:4-5 Let that day be darkness; let not God regard it from above, neither let the light shine upon it. Let darkness and the shadow of death stain it; let a cloud dwell on it; let the blackness of the day terrify it.
--------------------------------------------------------------------------------------------
Lamentations 3:7 He hath hedged me about, that I cannot get out: he hath made my chain heavy.
Job 3:23, Why is light given to a man whose way is hid, And whom God hath hedged in? (19:8) He has fenced up my way that I cannot pass, and he has set darkness in my paths.