Psalms - Chapter 39
David starts by saying that this Psalm is "for Yedusun." Yedusun was the name of one of the Levite families who sang David's Psalms, so this Psalm might have been composed with their singing in mind.
David says that he will guard his mouth at all times, as if with a muzzle, so that he will never question G-d, no matter what troubles may befall him. Even when his pursuers gloat in David's misfortunes, he won't say a word. (This is consistent with David's behavior when he was driven from his throne by his son Avshalom. At that time, he was taunted and cursed by Shimei Ben Gera, a relative of Saul, whom David succeeded as king. David declined to respond to Shimei's curses.)
David says that he has been silent for so long, it's as if he has lost the ability to speak altogether. His enemies troubled him so much that he was even unable to concentrate on his Torah studies. This intensified his pains and he burned inside. Finally, David could bear it no more and he spoke out, asking G-d how long he must endure his suffering. (The Talmud in Shabbos, 30a, says that David asked to know the day of his death.)
David continues that if he only knew the worth of his days, he would realize how insignificant he is. G-d has made his days few, easily counted. All human effort is nothing compared to G-d's eternal existence, therefore all of our deeds are fleeting and transient. (David uses the word "hevel," often translated "vanity" or "futility." This is a theme that will be exmined by his son Shlomo, Solomon, in greater detail in Koheles, the book of Ecclesiates.) Man spends his life groping in the darkness and the things he spends all his energy pursuing are ultimately worthless. A person stockpiles money, but he may never get to enjoy it and who knows where it will end up after his death?
So, with all this in mind, what exactly is it that David wants? He turns to G-d, hoping that his sins will not cause him to become an object of derision. He had been silent in the face of all his afflictions because he recognized that they came because of his sins. Now that he has learned his lesson, he asks that his ailments end. G-d's punishments are no laughing matter and they eat away at David like a moth through clothes - this demonstrates man's temporal nature.
David ends by asking G-d to hear his plea and not be silent to his tears. David is like a stranger before G-d; only He can decide whether or not David will be permitted to remain with Him. David prays that G-d allow him to regain his strength before he dies and is gone for good.