God is too free and wisdom is too profound for the retributive principle to be immutably true in every situation; rather, it is mutably true in many situations. And so we should not judge on the basis of the appearance of things but be slow to judge. We will protect ourselves from thinking that God is unjust; and we will more wisely endure the vagaries of life.
In my view, the Book of Job centres on Job’s three friends and Job trying to understand why Job was suffering, while assuming the retributive principle (an eye for an eye).
Rather, as the narrative couching of Job tells us (chs 1-2 and 38-42), behind the appearance of things (Job’s suffering in this case) lies deeper truths and wider realities.
That’s why Job 28 likens wisdom to mining below the surface level to the deeps of the earth to find what’s valuable. Even so, wisdom is yet hidden. We cannot comprehend wisdom in full.