When David wrote Psalm 23 he was certainly not thinking about the Lord’s Table but we can see a connection between the song and the supper.
Think especially about Psalm 23:5: “You prepare a table before me in the presence of my enemies; you anoint my head with oil; my cup overflows.” In the midst of David’s difficulties and dangers and attacks the Lord provided a meal of blessing and abundance. There was feeding and security and joy that his enemies could not steal.
We enjoy the same thing when we enjoy the Lord’s Supper. Our enemies are not present in the room (and if we think so, we should consider the communion we’re about to share with them), but we are gathered in the midst of deadly foes. The Lord has prepared a table for us. Even more, He has given us Himself as food. He has become our protector. He is our blessing and our overflow.
So surely goodness and mercy will follow us all the days of our lives and we will dwell in the house of the Lord forever. We are His covenant lambs. The table before us confirms it.