In Psalm 40, Verse 7 is hard to separate from verses 6 and 8 to show the context. David is speaking of the true requirements of the word of God, what is in the heart. It never was about the keeping of the law (because we never could), it was about the change of heart that comes from trusting Christ and the internal change that brings about the desire that David expresses in verse 8 of how he desires to do God’s will. That is true salvation. Many say they know Christ but the way they live shows they never have. When we are truly saved our greatest desire is to know and please Christ. Verses 6-8 ultimately speak of Christ and all He did when He came to earth to die for our sins. What do you desire most?
Psalm 40:7 Then I said, “Behold, I come; In the scroll of the book it is written of me.
Psalm 40:6 Sacrifice and offering You did not desire;
My ears You have opened.
Burnt offering and sin offering You did not require.
7 Then I said, “Behold, I come;
In the scroll of the book it is written of me.
8 I delight to do Your will, O my God,
And Your law is within my heart.”