In this chapter, David sings about God saving him from Saul and his other enemies.
This chapter foreshadows what we are soon approaching, the book of Psalms. Line after line, verse after verse, chapter after chapter, the Psalms are going to take a long time to get through and because David (ostensibly) authored many of them, there will be a lot of repeated concepts and idioms throughout.
This chapter in particular is nearly word-for-word identical with Psalm 18 which is interesting in and of itself. What it clearly demonstrates (as if there were any doubt) that these were originally independent books, so the author of Samuel did not assume that his readers would have a copy of the book of Psalms. Otherwise the redundancy would not have any point. With less certainty, we can hypothesize that the book of Psalms was being composed in a similar time frame to when the book of Samuel was written.
I don't want to discuss the book of Psalms in depth here, though. I'll just focus on the content of this Psalm and how it relates to David's life, which I think was the author's intent in placing it here.
In the first verse we find both the context and the purpose of David's song, which is that the LORD has delivered him from all his adversaries, of whom Saul was the greatest, and David wants to praise and honor God for what God has done in his life.
This chapter is drawn from after David had been saved from Saul, but otherwise it is difficult or impossible to figure out exactly when, during his lifetime, it was written. Since that is the case, I'm going to focus much more on the theological and poetic elements of this psalm rather than trying to relate it to specific events in David's life.
First of all, I really like verses 2-3. They contain a lot of repetitive elements, emphasizing David's possession of the LORD. He says the LORD is "my God". It emphasizes safety and defense from harm: rock (stability), fortress, savior, shield, refuge and deliverer. But more than that, David talks about God as being his. This is essentially relational and it shows that David has tremendous confidence in God, not just in his trust that God would bail him out of difficult situations, but because he felt like God was committed to him.
Second, what I really like about this chapter as a whole is the human-like and descriptive imagery that David uses to describe God. There are a lot of things to like about the book of Samuel, but if there's one thing I miss from the Pentateuch it is the much more interactive relationship the patriarchs had with God compared to people in the kingship period. God appeared to Abraham several times and wrestled with Jacob. Moses saw a burning bush and approached the LORD upon a burning mountain. In comparison, while God has still been influencing events in the lives of Saul and David, he has not been appearing with the intensity or frequency that we observed in prior epochs. As someone who is interested in descriptions of the LORD, this disappoints me somewhat. This chapter is quite different, however.
In this chapter, God is described as being like a stormcloud, surrounded in darkness and flashing out with lightning and thunder, with fire, wind and earthquakes, raging with power and wrath at all those who would harm his servants. Like the burning mountain that Moses saw, this is a benevolent violence and force. It is not coming to destroy, but rather to rescue and lift David out of the "many waters" that are seeking to drown and bury him, to cover him up that he may not rise again. The waters represent many peoples, and David feels like he was drowning in a torrent when the LORD came in strength to sweep him up and place him on solid ground.
Third, in verse 5 David talks about "waves of death" encompassing him. The term "waves of death" is based on the Hebrew word משבר, which translates as "crisis", but Rashi explains that the term refers to a stone seat that a woman would sit upon while giving birth to a child. Therefore in the psalm, David is alluding to himself as travailing like a woman giving birth to a child and as a metaphor, we can imagine his prayers as being like birth pangs as he is trying to bring about a change in his situation and in his life. Like a pregnant woman, David is going through waves of pain, surrounded by death and destruction on every side, until the LORD should emerge and rescue him.
In an even broader sense, we could say that David is going through the pangs of childbirth as he awaits the Messiah, the one who would tread upon the serpent's head (Gen 3:15). In a limited sense, Israel has been planted in the promised land and blessed with the favor of the LORD, but in a broad sense they are still waiting for the LORD to bring everything back to completion, to return the world to the perfect and deathless state that endured while mankind lived in the garden of Eden with the LORD. David praises the LORD for his salvation and rescuing him from death, and while this has a temporal fulfillment in how he was saved from Saul, there is also a prophetic aspect to this as David looks forward to his resurrection from the dead. Indeed, David could not truly be saved from death as he claimed were he not saved from the death of his body and soul by the power and mercy of God.
Israel was meant to be a sign of what is possible for those who obey and live in covenant with God. It was not meant to be the completion of God's acts amongst men, but to be a declaration of what God would do for those whom he loves and who follow him, and an invitation for all men to enter into a similar covenant. In the same way, David's salvation is also a sign and a declaration of the salvation that God would fulfill and make complete amongst all those who seek him the same way that David sought him. It was a salvation now, rescuing David from all his enemies, but it also foretells a greater salvation that would come and rescue David from the curse that came upon mankind after the sin of Adam. David praises God for the salvation that he receives now, and he also praises God for the salvation that he is anticipating in this psalm.
I am describing this passage as an allusion to the Exodus story, and Rashi agrees. When David speaks of the wrath of God causing earthquakes, fire, lightning and thunder, it is very likely that he is also alluding to the tremors of Mount Sinai when the LORD descended upon it in Exodus 19. The salvation that David describes could also be an allusion to the exodus from Egypt, because the "darkness" (v. 10, 12) could be a reference to the veil of darkness that separated the Egyptians from the Israelites and protected Israel from harm (Ex 14:19-20). In the same way, David almost directly references the crossing of the Red Sea in verse 16 when he says "the channels of the sea appeared, the foundations of the world were laid bare." This most directly refers to the crossing of the Red Sea. I also think part of what this means is that God sees and understands everything about the innermost parts of the world, and every part of the world is laid bare even as the hearts of men are also laid bare. The power of God is not just to change the world or destroy evil doers, but it is also to uncover and reveal what is hidden, so that the good or evil that dwells within creation and mankind may also be revealed. The salvation in verses 17-18 is therefore both the salvation of David, and also the salvation of Israel as they were freed from the threat of death that encompassed them.
This psalm is pretty amazing. There are five different things going on in this one passage (v. 5-19). On the one hand, David is talking about God saving him from Saul and his other enemies. On the other hand, he is referencing the exodus from Egypt and crossing the Red Sea. On the third hand, David is alluding to when the LORD came down on Mount Sinai and formed the covenant with Israel. On the fourth hand, David is using metaphorical language to describe God's activity as being like a storm cloud coming down from heaven and shooting lightning like a batch of arrows at his enemies, a force of nature coming to rescue him. On the fifth hand, I think this passage anticipates David's eventual salvation from death as he labors in prayer, like a woman laboring to bring forth a child. What I think is amazing about this is how there are so many layers all active at the same time, and with the same words David is talking about so many different things. It's like a triple entendre or something.
Verse 20 is particularly striking, and this is David's conclusion. Having described God's activity amongst men, now David is describing God's motivation: The LORD rescued David "because he delighted in me." What an incredible revelation. No wonder David has such confidence and trust in the LORD's protection, when he is convinced that God takes pleasure in David's life and David's heart.
Verse 20 is the end of the first logical segment of this psalm and the beginning of the second. From verses 1-19, we see the oppression of evil and sin and how God rescues David from all his enemies. In verses 20-28, David starts telling us why God protects and delivers him. David claims that he is righteous, innocent and he obeyed all the laws and commands of the LORD. We know that factually this isn't entirely true, as David sinned on several occasions. I think verse 25 is the key for understanding this passage: David says he was clean before God's eyes. David knew that he had sinned, but he also knew that he was forgiven and since he was forgiven, he was innocent in the eyes and judgment of God. As it is written: "The LORD has taken away your sin" (2 Samuel 11:13). David had sinned, but he also repented and in his repentence, he was made clean and innocent.
Verses 26-27 are also interesting. In a plain reading of the text, what David is saying is, "to the people who are kind, you show kindness to them." That is, God acts kindly towards people who are kind, and he acts with purity towards those who are pure. In a similar way, God does not act with evil towards the "perverted", but he is clever and does not allow them to get away with their perverted desires. To the kind he shows kindness, but to those who do evil he brings judgment.
I think there is a broader possible understanding of this passage. In a literal sense, David means that God acts kindly towards those who are kind. But in a more figurative way, we can understand that God reveals kindness as part of his nature towards those who have kindness as part of their nature. To people who are kind to others, God reveals to them that God himself is also kind to others, which is another way of saying that God brings specific revelations of his nature and character towards those who do good. Indeed, it is by adopting the goodness of God in our relation to others that we discover what God is truly like. The reason is that when we act out of goodness towards others, we begin to feel the emotions that govern the heart of God; by acting with purity, we understand what motivates God in his purity. When we act in kindness, we understand why God acts in kindness, because what motivates all of these things is love, and when we act in love, we understand the heart of God.
I don't see any one unifying theme in the rest of the psalm. David speaks a lot about God giving him victory over his enemies, using a mixture of metaphorical terms such as "the shield of your salvation". Once again, I get the sense that David is using double entendres, referring to both his specific salvation from harm, such as the threats of Saul, but also a more metaphorical "salvation" in a general sense.
There are a few more minor notes I could throw in, but I think I've said enough for this chapter.