"Yet you say, 'The way of the Lord is not just.' Hear now, O house of Israel: Is my way not just? Is it not your ways that are not just?
Ezekiel 18:25
Israel had become skilled at a theological dodge. They thought they had a brilliant intellectual reason for rejecting God. They thought that somehow they reasoned their way to moral high ground above God. Their rationale had to do with divine judgment. They blindly stated that innocent people die in acts that are deemed God's judgment. Therefore God was capricious and unfair in His display of His wrath. The implication was that capricious judgment was immoral because non-guilty people died.
This is an argument that agnostics and atheists like to raise today. So I find it interesting that God has addressed it in His Word so long ago. When we point a finger at God we assume ourselves innocent. That is the first fallacy. God makes it clear in Ezekiel 18 that He knows every human heart (something we are not capable of doing). There was no way that a righteous person would die in judgment for the sins of an unrighteous relative. God even goes so far as to say that He knows when the worst sinner repents and if such a person does what is right as fruit of their repentance, God will spare that person from death (Ezekiel 18:21-24). The opposite also holds true... if a righteous person chooses to abandon the truth and live in a non-repentant life that disobeys God, that person will be judged.
God's point is not that He is somehow inconsistent in the application of justice. It is that we are natural born sinners. Our perspective is warped. We are not just. God is perfectly just. So we cannot even evaluate our own hearts, let alone accuse God of unfairness. Such accusation is proof of our own moral impotency. When agnostics and philosophers committed to anti-supernaturalism accuse God in order to eliminate Theism as a belief system, they are doing what God told Israel was warped by sin. Only God can be righteous and evaluate what is holy and just.