This is a powerful declaration of David. There are many inferential connections in the assertion, like "The Lord is my Shepherd; He is an all-powerful Shepherd; He is an all-knowing Shepherd; He is all-present Shepherd; He never slumbers or sleeps; He is good and kind; He is a Caring Shepherd; He is a Rich Shepherd; He is a Loving Shepherd; therefore, I shall never lack anything."
When David calls God his shepherd, he recognizes God as his protector, provider, savior, and master.
There is nothing more damaging to the Christian life than the thought that "I am lacking something". The devil tried this with Eve and prevailed. He first tried to question if God forbade all the trees of the Garden. When she said, No, not every tree but only the tree of the fruit of the knowledge of good and evil, he questioned the motives of God as to why He had kept this one tree from them. Have you ever felt like why this or that one thing was kept from you? Instantly, Eve's eyes were turned away from all that God had given to the one thing He had not given to her. And, when she pondered on this, the desire for the forbidden fruit grew bigger and bigger and (as usually with human experience) her desire for all the things that God gave her dwarfed before the desire for the one forbidden thing. This single thing that she lacked (because the Shepherd didn't give her) grew into an abyss of wantedness in her. The result: sin, shame, and suffering.
Similarly so also with the Israelites in the wilderness. Their minds began to turn to what they didn't have (and, can there be a point where a person can say "I have everything"? Even the richest of men don't have all things), i.e. what God hadn't allotted to them. They lusted for meat (of a strange kind of course; or else, they certainly had flocks with them!). They lusted for the spices of Egypt. They began to find the manna that God gave them disgusting. They began to complain and murmur against the Shepherd of Israel. But, is it true that they were in want? Of course not. However, instead of declaring their joy in the Lord in psalms and praises, they were filled with grumblings and weepings. They found a reason to complain (Who cannot find?). The result: destruction in the wilderness. Unless the Shepherd leads us into the Promised Land, we can never enter it. But, how will you follow a Shepherd when you want Him to follow and fulfill all your longings all the time. But, David was not like that. He knew that what the Shepherd gave him was his contentment and satisfaction.
But, look at Joseph. When Potiphar's wife tried to seduce him into sleeping with him, he stood as a rock and replied: "My master has withheld nothing from me except you, because you are his wife. How then could I do such a wicked thing and sin against God?" He didn't become unrighteous in saying, "Why should I lack this experience when it is readily available?" He ran from Potiphar's wife. He ran from the temptation. He ran from sin. And, he had to suffer for this by being unjustly thrown into prison. But, God blessed him. The result: favor, promotion, power, prosperity, and purposefulness. God used him to save Israel. God used him to save the world from famine and starvation. He became the Prime Minister of Egypt.