David knows that if we are to serve God, it needs to be right now where He has put us in this world. When death comes it is all over. The next best thing is to make sure that the gospel is preached at our funeral so that others who are lost still have a chance to be saved and/or inspired to carry on for Christ because of the example of the life we have lived for the Lord. Our legacy can carry on through the witness and impact of the life we've lived for Christ here on earth.
David had a tender heart and at the end of the day he realized what an imperfect man he was and wept about it. We need more weeping when we find ourselves sinning. We must not be careless about this. We must remember that God gives grace to the humble. After his weeping, he asks what probably was the sinful companions who hung around him to depart from him. It appears that this psalm was written about the time he was on the run from Saul. As we look at those wanderings we do see some sinful practices in Davids life. David did have enemies in those days and he asks God to make them ashamed and to vex them. Throughout all his writing we see that David truly has a genuinely personal relationship with God. To be an effective believer we need to have one like that as well.