Psalm 4 is the polemic prayer of a hasid, a pious devotee of the Lord, against a majority or elite class who might be nominal believers, but lack the trust that differentiates true belief in God. The psalm is written in the first person but is likely a collective first person representing the community of the pious. I suspect that this psalm is representative of the theological reaction against the deuteronomic reform. It's attribution to David is intended to give authority to its position.
The second verse, "When I call, answer me oh righteous God, from this trouble you will deliver me, and hear my prayer" is the opening appeal. In the Hebrew, the word used for trouble here is "tsar", which also means "narrow". The word for deliverance is "hirchavta", from "rachav" which also means "wide", so there is a use of antonyms at the secondary level of meaning for emphasis. The verse is as much an expression of trust as a straight appeal.
The third verse is part of the prayer addressed to God but rhetorically addressed to the people who trample the honour of the pious, have empty values and pursue worthless goals. The psalmist is addressing these people over their heads to God. The people are called "bnei ish" rather than "bnei adam", that is, "sons of men" and not "sons of Adam (man)". This is a form of deprecation as "ben Adam" is usually a term of respect. Some commentators (Cassutto for example) think that the use of "bnei ish" might be intended to indicate people of high social standing, the merchant class or ruling elite.
The fourth verse, "Know that the Lord will give special consideration to his pious followers, the Lord will hear those who call to Him" is a both a declaration of faith, and a reproach rhetorically addressed to the ruling elite or majority.
The fifth verse continues this reproach, "Fear [God] and do not sin, say your prayers at bed time and sleep in peace". I translate the entire verse as a consistent imperative, with the first word "rigzu" as "fear", a shorthand for "Fear God", according to Cassutto, Amos Hacham, and the classical Jewish commentators. The Cambridge NEB translates this as "However angry in your hearts..." using the more common usage of "rogez" to mean anxiety or anger, but this breaks the simple imperative meaning of the verse.
The sixth verse continues the imperative, "Sacrifice sacrifices of justice and trust in the Lord". Amos Hacham interprets this as "Sacrifice just offerings and trust in the Lord", meaning, offerings that were obtained through just means and not from bribes, blackmail, or deceitful commerce. Cassutto interprets as "Make your sacrifices offering of [social] justice [rather than actual animals]".
The seventh verse goes back to directly addressing God and describing the behaviour of "many" who might be the same as the previous group addressed or could be a wider majority of nominal believers of lesser piety, "Lots of folks say, 'Who will bring us good? Oh God, shine the light of your face upon us!'". From the following verse it is clear that the "good" that these folks ask for are in fact "goods". This verse is possibly a dig at simplistic interpretation of the Deuteronomic reform that saw the covenant as a quid pro quo affair.
The eighth verse, "You gave me more happiness than [they have] when their grain and grape juice are plenty" is about the joy that comes from trust, though the word "trust" is not in this verse but is implicitly carried over from verse six.
Verse nine, "I will not only lie down but will even sleep in peace because you oh God alone let me live in security (or peace)". The word for security is "betach", same root as "bitchu", "trust" in verse six. This verse contrasts the sleep of the trusting hasid with the implicitly troubled sleep of the lesser than pious people addressed in verse five.
The psalm could also be intended as internal propaganda for the pious community against what appears to be a majority community of scoffers and crass commercial pursuit. This is an ageless issue in the faith community.
The reason for suspecting a polemic are the words of the plea of the people in verse seven that reflect the second verse of the priestly blessing (Numbers 6:25) and the expected material result of grain and grape juice mentioned in verse eight reflecting Deuteronomy 33:28-29.