Job, a good man, stripped by Satan, a foreshadowing of believer's experience of the cross. Satan accuses Job of only serving God for selfish reasons. God allows Satan to attack Job within stated limits. Satan is the tool of God that comes against Job, against Jesus at the cross, and against us as we experience the cross. Satan uses the elements, fire and wind, military/criminal violence, disease and bad advice from wives and friends. Job wants a trial to prove his innocence but in God's economy the cross must come to all, the good as well the evil. Job proving his innocence is irrelevant. It is not a matter of whether someone is good or evil. It is dying in order to live. All must die with Christ in order to live with Christ.
God allows Satan to attack Job for a good purpose just as God allowed Satan to put Jesus on the cross, to save the world. Job ends up in chap 42 with a double portion of blessing. This is the final outcome of Job's patient faith and endurance.
The friends give Job bad advice because they think like so many do today. They think that bad things don't happen to good people. Job is a good person . Job chapter 1 says so except 32:1 says he is self-righteous.
Job's friends' thinking is legalistic. Under law, the good are rewarded and the bad are punished. See Deut 27-30. Bad things don't happen to good people. But under law, you always get what you DESERVE. But under grace you many times get what you DON'T DESERVE. You get a cross you don't deserve and you get resurrection life and power that you don't deserve.
His friends consistent statement was, "Job, you must have sinned for all these bad things that are happening to you." Job says, "No, I have done nothing to deserve this. God, give me a trial and I will prove my innocence."