The final section of this psalm is a prayer for future deliverance (vv. 11-17), which is particularly interesting in this context. David had been in a situation so hopeless that he could only adequately describe it as being in a slimy, muddy pit. He had waited for God, and God had delivered him, lifting him out of the pit and setting his feet on a rock. Yet now, even though he had been delivered from great trouble, as recounted in verses 1-3, Israel's beloved king and poet still continues to have trouble and needs further help.

Jeremiah prophesied the coming of a new covenant, saying, "‘This is the covenant I will make with the house of Israel after that time,’ declares the LORD. ‘I will put my law in their minds and write it on their hearts. I will be their God, and they will be my people’" (Jer. 31:33). To Jeremiah, having the law in our hearts is a proper definition of what it means to be in a right relationship to God. Jesus also had much to say about the heart, often stressing that the people's hearts were calloused (cf. Matt. 13:15; Mark 7:6, 21). In regard to the law, Jesus said that the chief commandment is to "love the Lord your God with all your heart and with all your soul and with all your mind" (Matt. 22:37).

It is a characteristic of the psalms, particularly those of David, that they frequently first tell of the writer's personal experience of God's goodness and then reflect on that goodness, commending it to others. This is what the second section of Psalm 40 does (vv. 4-10). There are three parts.

The pit of defeat. Some people have a very different kind of pit from which they need to be lifted. It is the pit of personal defeat, whether at work or school or in the home or in some other setting or relationship. Some people would say that their entire lives have been one long and unending defeat. They have never succeeded at anything.

Psalm 40 tells of a man who was stuck in a slimy pit, bogged down in mud and mire, but then was rescued by God, who set his feet on a rock and gave him a firm place to stand. That man was King David.