David wrote this at a very low point in his life. His son, Absalom, had raised an army with the purpose of overthrowing him David had to flee Jerusalem as quickly as he could. By the time David reached a place of safety, he and everyone else was exhausted. In his despair, he cried out to God, and God answered him with a great calming spirit. David was able to then lay down and sleep restfully. He didn’t know what was happening, but his mind was at ease.
The next morning he “woke up in safety, for the Lord was watching over me”. Because the enemy had not yet arrived, he knew that God had answered his prayer. His courage returned and he was ready to face the battle because he knew the Lord would provide him victory.
When things go wrong in our lives, whether it is a minor problem or a great disaster, God wants us to depend on Him and be encouraged because He cares for us. The Scriptures say “give all your worries and cares to God, for He cares about you”. 1 Peter 5:7 (NLT).