The context is 1 Sam 21.10-15, a psalm of personal testimony. David, having been sent away from Achish (Abimelech), was in the cave of Adullam, considering God's faithfulness. David had experienced good and bad, had been close to the godly, and to the ungodly, and this Psalm reflects those experiences.
v1-3: Personal gratitude to God, for He had heard David's prayer and had delivered him. David invited others to share in praising God; see also v11.
v4: He delivered David, and He will deliver others; a personal experience of God's faithfulness must not be considered the only demonstration of God's faithfulness; we must not think selfishly about His blessings.
v5: David is confident that God will never disappoint. Others will look to Him, and be delivered also.
v6: David describes himself, "this poor man"; he knew he was not worthy of any kindness form the Lord; yet He heard him and saved him.
Notice the phrases; "all my fears" (v4), "all his troubles" (v6, 17, 19); the Lord knows how to deliver the righteous out of all things. Troubles might be the attacks of others; but they may also be self-inflicted. All are included here.
v7: God's blessing upon those who are His; His people are surrounded by good. But contrast the experience of Job (Job 16.13) and of Christ (Ps 22.12, 16). Our part is to seek Him in prayer; sought (v4), looked (v5), cried (v6).
v8-10: Seeking and finding; the Lord never disappoints those who trust Him; such is the experience that is ours.
We are to fear the Lord, showing reverence for Almighty God. See Ps 22.23, 25; 25.12, 14; 31.19; 33.8, 18.
v11-14: David gathers his few friends around him, to teach them the true ways of God. Unless we are obedient, he says, God's blessing will elude us. Essential to be obedient in practice; verses quoted in 1 Pet 3.10-12.
v15-16: The Lord knows those who are His; He makes a distinction between believers and unbelievers.
v17-18: Many righteous are also broken-hearted, because they have suffered at the hands of the unrighteous. The Lord hears them, He is near; he will deliver and save.
v19-22: The assurance of answered prayer; the righteous man, because he belongs to the Lord, will experience His blessing.