David is SO much like us! Apparently he was faced with a situation in which it would have been best for him simply to remain silent, to let the "wicked" have their say without answering, even when they spoke about him. And he succeeded for a while. He held it in as long as he could. But all the time he was almost bursting inwardly because of the their injustice, their falsehood, and their proudness. It's likely that if he'd continued to remain silent they would have "hanged themselves" with their own words. But he couldn't.
When he couldn't take it anymore and just had to defend himself, the inward dam burst, and a torrent of words escaped his mouth. He became nearly as bad as his accusers had been, and he sinned with his mouth - grievously. He knew he shouldn't have done it. He had purposed before the Lord to hold his tongue. But, as we often do, he failed, and now there were consequences. It didn't seem like the Lord was helping him, and he knew why - he had sinned.
God's covenant people Israel should never act like that! They should always trust Him and let Him take care of their problems instead of taking them into their own hands. But, like David, they fail, and God is dishonored by it.
But dear brothers and sisters, that's why David composed this psalm and introduced it into the daily worship - he knew everyone who sang it could relate to it, because such things happen to everyone. So he led them in this penitential song, a song of confession to God and prayer for His mercy and restoration. He knew they'd all need it.
In the first three verses, he simply tells God what he's done. Then, in the next three verses, he confesses is frailness, his foolishness, and the shortness of his time on this earth.
Finally, he confesses that the Lord is all he has. He returns to Him and begs His merciful forgiveness - that He would turn to him again because his life is too short to spend it apart from Him. He begs His gracious restoration by saying, "Hear my prayer, O Lord, and give ear to my cry; Do not be silent at my tears, for I am a stranger with You, a sojourner, as all my fathers were. Remove Your (reproachful) gaze from me, that I may regain strength, before I go away and am no more."
Has this ever happened to you? Have you ever "burst forth" with words that should never have been said? I suspect we all have. Confess your sin to your Lord. Seek His restoration. He's merciful.