Since Job has been insisting that he is righteous, how about considering God’s righteousness first? That will put Job’s situation, as well as the false understanding of God’s retributive justice on the part of his friends, in their proper perspectives. In verse 10, Elihu asks the debaters, “
So listen to me, you men of understanding. Far be it from God to do evil, from the Almighty to do wrong. He repays a man for what he has done; he brings upon him what his conduct deserves. It is unthinkable that God would do wrong, that the Almighty would pervert justice.”
Yes, God must punish sin, but will do so in his own time and ways. God is sovereign.