It's possible to compare the work of a Shepherd with that of the character of God as revealed in the scriptures:-
• In verse one, the animals lack nothing ("I shall not want"). God promises elsewhere in the bible always to provide for His people. For example, Genesis 22:14 (NIV):-
"So Abraham called that place The LORD Will Provide. And to this day it is said, “On the mountain of the LORD it will be provided.”"
Indeed, David's testimony is that of experiencing a God who provides an overflowing cup (verse 5). This has parallels with the New Testament, where Jesus speaks of what will happen to those who give to others:-
"good measure, pressed down, shaken together, and running over, will be given to you." (Luke 6:38 WEB)
• Just as a shepherd leads his sheep to rest and refreshment (psalm 23:2), so Christ invites His people to come to Him, and rest on Him (see Matthew 11:28).
God also promises always to be with us - this is a recurring theme of the psalm (see verse 4 "I will fear no evil: for thou art with me" and verse 6 "I will dwell in the house of the Lord forever"). It is also a recurring theme of the scriptures. For example, Jesus in Matthew 28 verse 20 (NLT) states:-
"And be sure of this: I am with you always, even to the end of the age.”
And Christ also promises His followers with an eternal home (John 14:2). The Old Testament has many examples of the Lord reassuring His people that He is with them. When Isaac goes to Beersheba, the Lord appears to him in the night and says:-
"Do not be afraid, for I am with you; I will bless you" (Genesis 26:24, NIV)
• In John Chapter 10, Jesus declares that he is the Good Shepherd, one who lays down His life for his sheep. He is their protector (John 10:12), just as David's testimony is one of God's rod and staff that comfort him through dark times (Psalm 23:4).