For the blessed David also had a fall like that which has now happened to you; and not this only but another also that followed it. I mean that of murder. What then? Did he remain prostrate? Did he not immediately rise up again with energy and place himself in position to fight the enemy? In fact, he wrestled with him so bravely that even after his death he was the protector of his offspring. For when Solomon had perpetrated great iniquity and had deserved countless deaths, God said that he would leave him the kingdom intact, thus speaking: “I will surely rend the kingdom out of your hand and will give it to your servant. Nevertheless I will not do this in your days.” Wherefore? “For David your father’s sake, I will take it out of the hand of your son.” And again when Hezekiah was about to run the greatest possible risk, although he was a righteous man, God said that he would aid him for the sake of this saint. “For I will cast my shield,” he says, “over this city to save it for my own...
The Lord’s goodness is immense, and frequently he finds his way to grant the salvation of the majority on account of a few just people. Why do I say on account of a few just people? Frequently, when a just person cannot be found in the present life, he takes pity on the living on account of the virtue of the departed and cries aloud in the words, “I will protect this city for my own sake and the sake of my servant David.” Even if they do not deserve to be saved, he is saying, and have no claim on salvation, yet since showing love is habitual with me and I am prompt to have pity and rescue them from disaster, for my own sake and the sake of my servant David I will act as a shield; he who passed on from this life many years before will prove the salvation of those who have fallen victim to their own indifference. - "Homilies on Genesis 42.24"