In Psalm 7, David is under very strong persecution, which is indicated by the image of the lion that has the strength to tear him into pieces, yet David still trusts in the Lord. The title of the psalm indicates that slanderous words had been spoken against David by Gush, a Benjamite. He was likely a companion or relative of King Saul, also a Benjamite, who was attempting to kill David at the time. It appears that Cush was eager to injure David, and this intensifies David's struggle for survival. It was at this time that David and his band of outlaws were hiding in the wilderness under God's protection.
David, however, was innocent of wrongdoing against Saul, both when they were friends and when David was in exile. It is probable that David is remembering the two occasions when he had the chance to kill Saul, his enemy, but he mercifully spared his life (see 1 Samuel 24:12, 13 and 26:18). David felt confident that he was innocent and had maintained his integrity, and so he cries out to God in the form of an oath, wherein he was willing to accept any punishment if he had done wrong (7:3-5). David urgently called upon God (7:6), not only to judge the wicked but to judge him as well (7:8). Like David, the righteous need not fear the judgment and scrutiny of God, for God Himself is their defense and Righteous Judge who is most just and "saves the upright in heart" (7:10).
David did not retaliate for the slanderous words hurled against him; rather, he left the retribution to the Lord (cf. Romans 12:19), confident that God's wrath, like the most sophisticated weapons of warfare, will come daily against the wicked (7:11-13). David was also confident that the one who sinfully slandered him would give birth to falsehood (compare James 1:15) and that God would see to it that the trouble he made for him would return on his own head (7:14-16; e.g. Haman, Esther 7:7-10). Upon considering God's faithfulness to the righteous, David bursts forth with praise to the Lord Most High (7:17).
Psalm 8 starts and ends with the same verse, glorifying the Lord whose matchless, majestic, and beautiful name (Yahweh) is Sovereign over all the earth. David may have written this joyous hymn of praise to God while he was a shepherd boy, having much time in the open fields to ponder the greatness of God. As he looked up into the night sky over the rolling hills around Bethlehem, he was filled with awe and wonder at the beauty of the starry heavens which he perceived as clearly reflecting God's glory (19:1). Such majesty demanded praise for the Creator. Because of his young age, David may have been referring to himself when he sang, "Out of the mouth of babes and infants You have ordained strength [or 'praise']" (8:2). Jesus Christ quoted this verse as referring to Himself (Matthew 21:16). In praising God, we receive divine strength, and David discovered this from personal experience: He was enabled by God to kill both a vicious bear and a lion (1 Samuel 17:34-37). When we praise God, the enemy is silenced; Satan's roar cannot be heard.
The wonder of God's greatness and glory in creation, especially in the great expanse above, caused David to marvel at God's condescension to even consider mankind, who is comparatively so small and insignificant. "What is man that You are mindful of him, and the son of man that You visit [attentively and gracefully care for] him?" (8:4). David was overcome with a feeling of unworthiness and inferiority before the majesty of God. Compared to God, who is perfect, has all authority, and is the Source of being, man seems so weak, imperfect, finite, and even filthy; yet man had been honoured by God by giving him dominion (responsibility as a steward) over all His creation, simply because man had been made in His spiritual image and given a moral sense. Man was therefore the crown of God's creation. We are of great value to God and hold a special place in His heart, for He loves all mankind, and even before the foundation of the world, He provided redemption for us. Because of God's love and care, He visited man through the incarnation of Jesus Christ. Christ's visitation was the ultimate in divine condescension, which still causes us to marvel (see Hebrews 2:5-9). God came in the flesh and, in the fullest meaning of Psalm 8:6, all things have been put under His feet (1 Corinthians 15:27).