Nevertheless, as a Christian who has been redeemed by Christ's perfect blood, one may speak and pray this Psalm with assurance. At salvation, Christ's righteousness was imputed into the born-again, so that it no longer be the Christian that lives, but Christ in them (Galatians 2:20). So, in some beautiful cosmic transaction, the Father God no longer sees the fallen human believer, but a positional-perfect child of God. This does not mean we are totally perfected (sanctified), but we are on the road getting there (1 Peter 2:2). So He sees a Christian as if he's perfect, but of course he is not yet. That full-perfection happens when the believer is glorified with Christ (1 John 3:2).
Until that full glorification, the Christian may still pray Psalm 17, because although in his mortal flesh he may not be sinless, he is indeed positionally perfect, because he has taken on the perfect sacrifice of Jesus Christ.
David calls out to God for help, citing his sincerity and uprightness (v. 1) as worthy reasons for God to help. He asks God to behold the things that are equal (v. 2). This implies that David has lived righteously, similarly to a business man who has equal scales with which to measure goods (Proverbs 11:1; 16:11). This means David is saying he has defrauded no one and has dealt fairly in all his doings. He implores God to let his sentence, or judgment, come from God's presence. The psalmist seems comfortable asking for God Himself to hand down judgment since he has been sincere and dealt uprightly.
In verse three, David recounts how God has already tried, or proved, his heart and visited him in the night. "Night," here, may represent a spiritually dark time in David's life. This seems to be why David is comfortable having God judge him: Even in a spiritually dark time, perhaps depression, David has not transgressed—even with his mouth! The mouth, or speech or tongue, is a particularly difficult thing to control. James writes that if someone is able to control his tongue, he is able to control his whole body (James 3:2).
In verses four and five, David measures himself against other men. He gives two reasons for why he has been able to remain upright: 1. The Words of God's lips (following His commands) and by asking God to hold up the goings of his paths (relying on God's preserving power).
Now in verse six, David moves from defending his character to referring to God's character. David declares that God hears (v. 6), God has marvelous loving-kindness and saves those who put their trust in Him (v. 7), he is fond of his children and eyes them as a treasured possession (v. 8a), and God protects them under His wings from oppressors and enemies(v. 8b-9).
Next, the psalmist describes the characteristics of enemies of the upright. Enemies of God's children are described as "inclosed in their own fat" (v. 10). This implies their greed has enveloped them as obesity may envelop a glutton, to the point to where their heart no longer has pity. They also speak haughtily, and surround the godly seeking to break them down with proud stares and vicious words. Verse twelve explains that they may even be as patient as a young lion lurking about in secret, waiting for the right moment for a surprise attack.
Now that David has made the case for his righteousness and the enemies' evil intent, he invokes God to cast the wicked down so to deliver his soul from them (v. 13). David then recounts how the wicked have their portion in the present life: treasure, children, and an inheritance to leave to their decedents (14). As the old saying goes, “For the Christian, this world is the most Hell they will ever experience. For the ungodly, this world is the most Heaven they will ever experience.”
As for David, he seems satisfied with his present portion—to be so near to God as to see God's face. It does not seem to imply that David literally saw God's face, but rather that God is very near to David because of David's righteousness and brokenness (34:15; 18). Also, to be like God when he awakes. This may have two meanings: to be like God after the Second Coming of Christ (1 John 3:2; 1 Corinthians 15:53-54), but also with each new morning to become more and more like God through the process of sanctification (Lamentations 3:22-23), as the Christian ought to daily be in the process of sanctification (2 Corinthians 2:13).
Therefore, David, though perhaps panicked at first, slowly recalls how God is just, sovereign, and able to rescue him. One day, David reminds himself, he will receive his sentence or judgment from God's presence! He will finally be safe under God's wing, literally in His presence.