What does Psalm 139:5 mean?
David relates his confidence that God "hems him in." This idea comes from the Hebrew word tsuwr, which is often used of a military siege or fortification. A closely-related term is used in reference to ideas such as rocks or strength. In this context, it's meant to suggest guarding a valuable object. This statement attests to the Lord's protection of His people.The fact that God's hand was on David adds further evidence of the Lord's protection of His people. Although His hand brings judgment to the wicked, it brings grace and comfort to the righteous. He guards us on all sides. We may feel weak at times, but the Lord is always with us to keep us and strengthen us. Isaiah 40:28–31 points out that He does not faint or grow weary, but gives power to the faint and increases strength to those who are exhausted. Whoever waits on the Lord shall receive renewed strength and energy. Jesus promised that He and His Father keep us safe in their hands (John 10:28–29).
Psalm 139:1–6 extols God's infinite knowledge. David views God as knowing all about him: when he sits down and gets up, his thoughts and conduct, and even the words that are in his mind before he expresses them. He states that God's knowledge is far beyond his comprehension. This section of the psalm precedes the section that focuses on God's omnipresence—his presence everywhere.
In this psalm David marvels at God's amazing characteristics. God knows everything about him: where he goes, all David's thoughts and everything about his conduct. The Lord knows what David will say even before David says it. There is no place David can go that God isn't already present. David marvels at God's creative work in the womb. He is thankful for God's innumerable thoughts for him and for God's presence day and night. Finally, David's thoughts turn to the wicked. He considers them God's enemies and his, and longs for God to slay them. David is disgusted by evil people because they rail against God and take His name in vain. He asks God to search his heart to see if any sin is there, and he asks God to lead him in the way everlasting.