I used to do a fair bit of theoretical physics. And one of the things that theoretical physicists are especially interested in is finding a theory of everything - one theory which explains all the physical phenomena we see in the universe.
I think David would agree with them that there's one dynamic underlying everything - one basic principle which the universe runs on. But David wouldn't look for the answer in quantum field theory or superstrings. For David, the single dynamic underlying the whole universe is this - worship. Everything that happens to people, everything that God does, according to David, is somehow because of worship.
Maybe that seems a bit weird to you, but bear with me.
The way that most people think most of the time is that worship is a response - God does something amazing for us, so we praise and worship him. And that's what happens in v1-3. David praises God for rescuing him from the grave and from going down into the pit. It's interesting that in v2 he uses "O Lord my God" rather than just "O Lord" like in v1,3. It's kind of an intense awareness of God's closeness to him, and the fact he doesn't use that language in v1 and 3 makes it stand out all the more in v2.
Then in v4-5 we get a slight development. Here, David generalises his own experience to the rest of the nation, and tells them that they can praise God because of what he has seen God is like, and that his love is so much stronger than his anger.
In verses 6 and 7, David develops this theme to describe his own individual situation. His security comes only from God's favour. We may think that mountains stand firm on their own, but it's only when God wants them to. When he hides his face, it doesn't matter how strong the mountain is, it won't stand firm. So why does God show his favour sometimes and hide his face other times? It's not just capricious, as we see in v8-10.
David calls to God for mercy - he recognises he needs it. But it's really interesting how his call is motivated, because it isn't actually about him. David knows that he isn't the centre of the universe, but doesn't then make the mistake that we so often make and assume that everyone is the centre of their own universe. David knows that God's glory and worshipping God is what it is all about. So his prayer for deliverance is motivated by the fact that he knows he will be praising God when God delivers him. Why does David want God to spare him? So that he can praise God for his faithfulness. Prayer motivated by a desire for God to be worshipped.
David doesn't worship because he has been saved, he is saved so that he can worship. Worship is so big and important that it's even behind the doctrine of salvation.
And we see the same again in v11-12.
You turned my wailing into dancing;
you removed my sackcloth and clothed me with joy,
that my heart may sing to you and not be silent.
O LORD my God, I will give you thanks forever.
Psalm 30:11-12, NIV
Why did God save David and clothe him with joy? So that his heart could sing to God and not be silent.
Quick application. Have we been saved? If so, we've been saved so that we can praise God?
Do we want to be saved? Why?
Do we recognise that the underlying dynamic of everything that happens in the universe is God's praise? Are we willing to make that the underlying dynamic of everything that we do?