There's one truth that every DM will discover sooner or later in their Dungeons & Dragons campaign: even a full party of adventurers needs a few other friends. Sometimes, in the midst of all the D&D narrative-building that needs to be done, it's hard to make an NPC that the other players actively want to revisit on a regular basis—but in just a few steps, it can be done.
Build Off Of Players' Interest
Ever heard of the "murderhobo" party-type? It's that bloodthirsty gang of adventurers who go around and killing pretty much anything that gets in their way, whether it's a D&D monster or an NPC intended to be actually helpful. A party acting like that is generally a good sign that players aren't getting attached to their NPCs—so then it's time to find out which qualities the party does appreciate in potential outside friends.
When the party is meeting a wide range of NPCs, focus on the one they showed the most interest in and work on expanding that NPC's role in the game. A simple shopkeeper or bartender might become the party's new best friend if players take a shine to them. Maybe they're undercover, or maybe they used to be an adventurer too in their day; it's not too hard to give an NPC a reason to interact, and even sometimes travel with, the party. The DM can elevate any NPC, even those intended to be a one-off adventure hook-type,to a regular in the campaign.
Make Distinct Characters
DMs don't need dozens of NPCs in play at all times; rather, a small cast of beloved characters will do the trick--without being too much strain on the DM. How to make a character "distinct"? The first step to making a memorable NPC should be working on that first impression: a description of the NPC's appearance, mannerisms, and quirky habits go a long way. Bonus points if the NPC has their own recognizable "voice" separate from all the others. Sometimes coming up with a voice can be daunting, but any DM can take their roleplaying to that level.
If these NPCs are going to be truly likable, then their personalities need to be fully fleshed out: they need to be relatable on some level, they need to show warmth and vulnerability (or at least be entertaining), they need flaws to go along with all the positive aspects of their personality, and they need to feel authentic--as in, they need to be somebody the players trust. No insight checks needed for close friends of the party!
Then, double down on all that by revisiting the NPC. Too many NPCs will blur together without attracting any interest, but using one well-developed NPC for multiple story points in the campaign will make them continue to stand out.
A Good NPC is a Useful NPC
If the NPC is useful in some way, the party is that much more likely to voluntarily return to them. Sure, that sounds a little shallow, but there's a good reason. In a game based on moving from D&D adventure to adventure, why keep returning to an NPC who has nothing to contribute and no real connection to the events? A likable NPC has to have at least one of those. Plus, most people would rather spend time with someone who shows a willingness to help others.
So, create NPCs who can provide a service to the party that they can't do themselves, while not making them more powerful than the actual PCs. Maybe the players will need a guide to some far-flung ruin or someone privy to secrets, a ship captain or a wizard who can cast something the party spellcaster can't. NPCs who help the party without stealing anyone else's limelight are the ones who tend to stick around.
Let the Party Come to the Rescue
Asking for help can go a long way towards building a relationship--and when the party saves someone's life, they often get attached to that person. They get invested in the NPC's life because they feel more connected to it after doing such a favor. So, the next time a plot hook is needed, think about who is asking for help and why. D&D campaigns are an ongoing saga, but they become easier to emotionally invest in when the stories are about people (rather than just keeping the focus on the much more impersonal "bigger picture").
Giving players a personal reason driven by a well-developed NPC to do the next quest will make them even more excited to get going. And in the future that NPC can be the source of more adventure hooks, or even just join the party as a guide on some other quest.
Once the NPC is Made, Don't Kill Them Off
This one might seem obvious, but should the urge to "fridge" an NPC arise (fridging being the annoying practice of killing off an NPC in order to provoke the party into action), resist it. Killing off everyone the party loves will just return them right back to that "murderhobo" state because they've learned not to get attached.
Maybe the party invites their adventurer friend to a monster fight, and maybe that NPC gets badly hurt through the natural flow of combat, but the party still has agency through all that and the DM is only doing what they feel the monster would instinctually do. Killing an NPC without even giving players the chance to save them? That's when things get rocky.
The fact is, when players become attached to NPCs, D&D becomes more fun for them. Those NPCs become another big reason for the party to do the things they do; saving towns, solving problems and protecting at least a few specific people. A good NPC makes the game world that much more of an immersive experience for everyone involved.