This Psalm was written by David while he was hiding from King Saul in a cave. Saul was seeking David to kill him. David was a threat to Saul, as David was prophesied to replace Saul as King of Israel.
David was in a hopeless situation, and he knew it was only a matter of time before Saul found him. So, David reached out to God for help. God was David’s only option. David said, “There is no escape for me; no one cares for my soul. I cried out to Thee, Lord; I said, “Thou art my refuge, my portion in the land of the living. God give heed to my cry, for I am brought very low. Deliver me from my persecutors, for they are too strong for me.”
David was actually in a very good place spiritually. He had no option but to trust in God. David had to rely on his Faith in God to save him.
God did save David. In a similar manner, God wants us to rely on Him for help in our lives. He wants us to have Faith in Him. The Bible says without Faith it is impossible to please God. When we trust in God and reach out to Him, He will hear us. He will indeed help us out of seemingly hopeless situations.