This psalm is intensely personal, but since it's also the prayer of the king, every Israelite should want to enter into it with him. After all, to pray for the king's concerns is to pray for the welfare of the people as well.
With this in mind, the worshipper is led to begin with David's own urgent petition. He prays, "Preserve me, O God, for in You I put my trust." David is asking that his life be preserved for Israel's sake - that he might continue usefully and fruitfully as their king.
Then, having gotten the most important thing "off his chest," he continues in a more confessional mode, a mode in which he simply confesses that he, David, is nothing apart from Israel's true King in heaven.
In fact, David says, it would just be in the best interests of the true King in heaven to answer the prayer of this psalm. That's because the prayer is really for the sake of God's own beloved people. We could paraphrase, "Do these things for me, Lord, because You are my Lord - my goodness is nothing apart from You - and Your people are the excellent ones, in whom is all my delight!" In other words, he's asking for help from the Lord not only because the Lord is the only help there is, but also because that help will benefit the people Jehovah loves as well. It is in God's best interest to help David, because He will thus be helping the shepherd of His people.
David continues by confessing that anyone who seeks after any other god is only pursuing sorrow, and that he himself doesn't intend to go their way at all. He's glad to tell Jehovah that He alone is his eternal resting place - that He means everything to him - because all of God's goodness to him thus far has been wonderful indeed.
Not only so, but he also confesses that the instruction the Lord has given him is all he'll ever need, and that he knows that as long as he keeps the Lord before Him, he'll always be safe! In fact, he says, "Therefore my heart is glad and my glory rejoices; my flesh also will rest in hope." So joyful do such thoughts make him, in fact, that he says that he knows that even in death there will be no loss, because the Lord "will show me the path of life," and "in Your presence is fullness of joy; at Your right hand are pleasures forevermore!"
It's important for us to realize that the relationship of our Lord Jesus Christ to His Father was very similar to the one David had with the same God. In fact, our Lord quotes these very verses as belonging to Him as well as to David. As in David's case, our Lord's relationship to the Father was one of joy, trust, and love to God's people. In fact, even though our Savior had to experience all the curse of our sin and all the trials we must experience, yet He could still rejoice because it would bring salvation to us! And, most importantly as we read this psalm, He can lead us to that same joy and trust by His Spirit.
It would be very good for us to come before our Lord with David's attitude of love to God and His people. In our cries to Him for help we too, after beginning with a simple statement of need, should tell Him of our love for His people. Then we too, as in David's case, need to be so taken up with Who and What the Lord Himself is to us, that we can end our prayer as he did by expressing our confidence and joy in Him! We need to meditate on what He has given us - upon the "good inheritance" we have when we have Him and are among His people. We need to consider how great it is to be associated with those people and to know that both they and ourselves are going to be forever in His presence! Then, in union with our Lord Jesus Christ, we too can sing praise to Him!