Not only does it sound unfair, but it is directly contradicted by the Book of D’varim, which says, “Parents shall not be put to death for their children, nor children for their parents: each shall be put to death for his own wrongdoing” (Deut. 24:16).
Ezekiel says, “The son shall not bear the iniquity of the father, nor the father the iniquity of the son: the righteousness of the righteous shall be with his own self and the wickedness of the wicked shall be with his own self” (Ezek. 18:19).
Sforno tells us that in ancient history the king punished not only those who personally rebelled against him but the members of their families too.
In Assyria the relatives of someone who committed bloodshed could be punished. In Babylon there was a similar rule in relation to the family of a builder who put up a house that collapsed.
This made Judaism highly uneasy. The Targum explains the Second Commandment by adding, “…if the children continue the evil ways of their fathers”.
Ibn Ezra says that the Hebrew poked in Ex. 20:5 is to be translated not as “visits” but “remembers”.
If the child does evil, God remembers that there is a family tradition and brings it to be bear upon the fate of the child – but if the child overcomes a family taint, God does not punish him for what the parent has done but works backwards and uses the child’s good deeds to mitigate the effect of the parent’s wrongdoing.
It goes without saying that the principle of “No extension of guilt” is or ought to be still very much part of Biblical ethics.