Psalm 21:4 (ESV)

4 He asked life of you; you gave it to him, length of days forever and ever.

It is not just about a long life, but he desires a long life in order to serve as king of God’s people. God gave that to him. This is particularly striking when we think of the early death threats from Saul before David became king. And later the coup on the part of Absalom descent on David. He receives a long period as king from God the Lord.

In this verse we taste a messianic message in addition to a few other texts: Psalm 61:6–7, Prolong the life of the king; may his years endure to all generations! May he be enthroned forever before God; appoint steadfast love and faithfulness to watch over him! Psalm 2:8 (in fact, all of Psalm 2:1–12 is messianic), Ask of me, and I will make the nations your heritage, and the ends of the earth your possession. And 2 Samuel 7:13–16, as a covenant between the Lord and David, also speaks plainly, I will establish the throne of his kingdom forever…my steadfast love will not depart from him…your house and your kingdom shall be made sure forever before me. Your throne shall be established forever.