As a general rule, I don't think undead/necromancy should be automatically be evil (a good example would be the use of necromancy by the Dunmer in TES, where being chosen to guard your family tomb is seen as a great honour, and the families highly venerates their ancestors, even if they are undead monstrosities), or Evil as in alignment-Evil. But in settings based on DnD and derivates, and it's mythology? Yeah, in those undead is definitely evil. See, undead aren't just some frankenstein-esque dead bodies brought back to life but by magic instead of lightning, they're walking scars in the natural world. They're not just "undead" as in an animated mass of dead matter, but actively "anti-life". Using such a thing "for good purposes" would be a Neutral act at best.
A case could be made for intelligent undead, I agree. But generally, I tend to think of it as the Negative Energy being an inherently corruptive force and that once you basically become a direct link to the Negative Energy plane, there won't be much left of your person that was like it was before. I've also thought (while I'm fairly expecting that this will lead to inconsistencies with the rest of the setting) that once you go undead, your soul is destroyed, and the Negative Energy sort of just seeps into the you-shaped hole in your "soul space", creating something that is very much like you, and definitely based on you, but also very different.
But yes, there are examples of individual exceptions where a person has been able to overcome the "corruption" of te Negative Energy and become a Good undead creature. Liches, at least. Probably vampires. And yeah, then there's the Baelnorn, the Good elven liches. I don't really like those at all, they reek of "special awesome Elven magic that enables us to do things you can't so we can be super special because elven magic!" and I don't think that is particularly interesting.
And lastly, there is the implication that one could potentially create the equivalent "Good" undead by using Positive Energy ( or perhaps Neutral by using both Positive and Negative energy and making sure the streams do not cross). I'm not sure this has been explored by any DnD setting in any particular way, unfortunately.
Fakedit: ninja'd by Sergius. Apparently it may have been explored?