The Talmud (Pesachim 119b) pictures the end of days as a banquet. A great cup of wine — two hundred and twenty-one logs, more than a third of a hogshead — will be brought to the table, and the honor of leading the blessing will pass from patriarch to patriarch.
First it will be offered to Abraham. But Abraham will decline, because he fathered Ishmael. It will be offered to Isaac, who will decline because he fathered Esau. It will be offered to Jacob, who will decline because he married two sisters in one lifetime, contrary to the later law.
Then the cup will be offered to Moses. He, too, will decline — because he was judged unworthy to enter the Promised Land, or even to be buried in it. Then Joshua. Joshua will plead unworthiness, the Talmud says, because he had no son to carry his name.
And finally the cup will come to David. David, the adulterer, the killer, the weeping penitent of Psalm 51 — David will take the cup without flinching. "Yes," he will say, "I will bless, for I am worthy to bless." And he will quote his own words back to himself (Psalms 116:13): I will take the cup of salvation, and call upon the name of the Lord.
Every ancestor before him will have refused out of modesty. David will accept out of teshuvah — the knowledge that a soul purified by repentance is closer to God than a soul that never fell.