Psalm 25 finds David in the midst of duel crises. He is facing an outward crisis of enemies marching towards him. As well, David faces an inward crisis as he deals with his sins. As both crises press upon him from both sides, David is forced to cry out to God and confess what he cannot do for himself. He asks not only for forgiveness but also for God’s deliverance.
The superscription of Psalm 23 states that this psalm is written by David. Before becoming king, David’s vocation was that of a shepherd. 1 Samuel 16:11 — And Samuel said to Jesse, Are these all the children? And he said, There remains yet the youngest, and behold, he is tending the sheep. Then Samuel said to Jesse, Send and bring him; for we will not sit down until he comes here. David knew all to well what it meant to be a shepherd and how sheep tend to act. So as David posits his relationship with YHWH, he comes to understand that he is as dependent upon God as his sheep are of him. So David pens Psalm 23 as an exposé of God as a Shepherd.
Psalm 21 is a song of past and future victory in battle. The battle is won in both the past and the future through the power of God. As the superscription states, Psalm 21 is a psalm of David. David went to battle knowing that God would deliver him. In the first half of this psalm, David prayed for victory, confident that God would answer in the affirmative because of His mercy, grace, and power. In the second half of this psalm, David experiences God’s deliverance but also comes to the realization that God’s deliverance for him also comes with God’s destruction of his enemies.