Exodus 20:5-6 (also Dt 5:9-10)
I, the Lord your God, am a jealous God, punishing the children for the sin of the fathers to the third and fourth generation of those who hate me, but showing love to a thousand generations of those who love me and keep my commandments.
So when God destroyed the cities of the plain, he remembered Abraham, and he brought Lot out of the catastrophe that overthrew the cities where Lot had lived.
Lot and his two daughters left Zoar and settled in the mountains, for he was afraid to stay in Zoar. He and his two daughters lived in a cave. One day the older daughter said to the younger, "Our father is old, and there is no man around here to lie with us, as is the custom all over the earth. Let's get our father to drink wine and then lie with him and preserve our family line through our father."
They will pay for their sins because they rejected my laws and abhorred my decrees. Yet in spite of this, when they are in the land of their enemies, I will not reject them or abhor them so as to destroy them completely, breaking my covenant with them. I am the Lord their God. But for their sake I will remember the covenant with their ancestors whom I brought out of Egypt in the sight of the nations to be their God.
2 Kings 21:9
But the people did not listen. Manasseh led them astray, so that they did more evil than the nations the Lord had destroyed before the Israelites.
Is it unfair of God to show extra mercy to the families and descendents of righteous people, when they may not be righteous themselves? Why were Lot's daughters spared, when they were no paragons of virtue? Why were the Israelites spared and sent into exile instead of being destroyed like other nations, who were actually less evil than the Israelites?
The blessings received by a righteous person's family only affected their life on earth, not their ultimate destiny in the afterlife. The virtue of Lot and Abraham didn't guarantee their descendents a place in heaven, only a second chance on Earth. As for the nation of Israel, it could be that the evil nations that God destroyed wouldn't have benefited from yet another chance to repent, whereas some of the Israelites did repent.
Something else to keep in mind is that while God's blessings (and punishments) handed out on Earth may seem unfair, God may be using them to bring about good. For instance, an evil person may eventually realize that his blessings come from God and decide to follow God (see a real-life example). Likewise, a hardship befalling a "good" person may be used to discipline them or to teach them to trust God for provision. However, people who receive second chances or blessings will be held accountable for how they respond to them (Lk 12:48, Mt 18:23-35 - thanks to John Allister for reminding me of this).