“As for me, I said in my prosperity, “I shall never be moved.” By your favor, O Lord, you made my mountain stand strong; you hid your face; I was dismayed.” -Psalm 30:6–7
Here David appears to be drawing on the Law, the Pentateuch, for his theology. At the end of the book of Deuteronomy, God exhorts Moses before he dies, telling him of Israel’s apostasy and how their violation of God’s covenant with them will affect them.
“And the Lord said to Moses, “Behold, you are about to lie down with your fathers. Then this people will rise and whore after the foreign gods among them in the land that they are entering, and they will forsake me and break my covenant that I have made with them. Then my anger will be kindled against them in that day, and I will forsake them and hide my face from them, and they will be devoured. And many evils and troubles will come upon them, so that they will say in that day, ‘Have not these evils come upon us because our God is not among us?’” -Deuteronomy 31:16–17
In David’s pride, he was assured of his own steadfastness, but he quickly learned not to depend on himself. It’s easy to boast of our faithfulness when things are going well and temptation is not looking us in the face—in our “prosperity.” But when we fall, and we will fall (Proverbs 16:18), we discover how much we really need the Lord.
Through the Lord’s chastisement, David came to realize it was God who made him steadfast like a mountain. When David turned from depending on the Lord to depending on his own righteousness, the Lord his face. And, that is when evils and troubles came. That is when he was dismayed.