I've only had one that worked, probably because I was actively trying to keep him from being a DMPC. (I'd learned my lesson from a previous NPC I was too attached to and became the DMPC. The fact it had a plot-based shelf life didn't help since it was the star of that particular sub plot. It was the crappiest campaign arc I'd ever run and I still feel guilty about it 15 years later)
This time around I had an NPC I wanted to be a kind of social foil to the PCs. He was a Krynnish Irda, an almost mythically insular race, for those who don't know. The goal was the "alien mirror", causing the players to see inconsistencies in the "traditional" quasi-european feudal mindset of Solamnia. His motivation was that the players once caught him, literally scared him out of a tree, then splinted his arm and let him go. This was completely at odds with his subculture's view on the Races of Man and made him doubt his own culture's deeply held concepts.
So H'orst went rogue (well, he's a paladin, actually) and left his people to see what the Races of Man were really like. Being a juvenile, he wasn't as powerful as the Irda of legend. His shapeshifting was much more limited and he had only one or two 1/day spell-likes. He was very, very strong and quite smart but uninformed and untrianed so he was no threat to the PC's egos.
His catch-phrase became "I'll save you!" because when something would seriously hurt a PC, he'd charge it to act as a distraction. He had just enough hit points, AC, and weaponry (thanks to gear the party bought for him) that he could make himself a bigger threat at least long enough for the PC to seek healing. Later, when he got paladin spellcasting and acquired his Irda fast-healing he became much more of a bruiser, however he was never quite in the PC's league.
I think it was the fact the PCs got to train him, show him the ropes, and then watched him bloom that made him their favorite. It took a long time for him to ever outperform the PCs, and even then it was often more along the lines of making knowledge skill checks that others shouldn't have failed but the dice came up 1 or 2. (e.g. wise wizard "Hmm, magic coins don't ring a bell." DMPC - "Didn't you tell me about Fistandantilus making coins that cursed anyone who went back on a contract?" WW - "Why yes, yes I did.")
And he was their favorite more than mine. I needed him to leave the group for plot reasons but they did their darnedest to keep him around. They knew what his goals were and how they fit into the party's overall plan, but they still dragged their feet in letting him go. As the selfish-evil party rogue put it, "Who else but a bleeding heart paladin can I count on to come and save my bacon?"