Undead are generally evil because the cosmology says they are. I want to build a cosmology where undead are not intrinsically evil (but can be if, say, animated by demons). Most undead encountered by the heroes will be evil and need slaying, but otherwise there are societies where people donate their bodies after death to serve the community or where undead form respected members of the community. What rules changes need I make to allow this?
You don't need to change anything
As far as the rules are concerned, the alignment of NPCs is under the complete control of the DM. In the DM basic rules, page 3 under alignment, we are told (similar rules can be found in the monster manual):
The alignment specified in a monster’s stat block is the default. Feel free to depart from it and change a monster’s alignment to suit the needs of your campaign. If you want a good-aligned green dragon or an evil storm giant, there’s nothing stopping you
The only thing you need to do is find a way for the players to discover that not all undead are evil in this world. The manner by which they discover that is the story, which is completely up to your discretion. Though, you could for example, just tell the players outright if this is common world knowledge, or let them discover it on their own by interacting with the world and the people in it.
With D&D 5e, a lot of what was "good" and "evil" in earlier editions was replaced to work on demons, undead and angels, assuming they are arch-typical good and evil beings. So allowing "good" undead will affect this abilities and spells in ways that are hard to foresee.
As long as those undead that the characters encounter as... well, encounters, being it combat or riddles to overcome stay evil, there are no rule changes necessary. All the abilities characters have will work just as before for their daily adventuring.
It might be more in line with the existing rules, to handle normal undead enemies as the "evil undead" they are supposed to be and make your society have constructs made by the bones of the dead. That way, you could have it all, without any changes. The characters abilities will still work as previously laid out and your "good" undead would in type not be "undead" but constructs. So again, all your player characters powers work just as advertised (in this case, not at all against the "good" undead, that are neutral constructs then).
Previous editions of D&D had powers, class features, and spells that changed or were not available to members of a certain alignment, making your character's moral code as much of an optimization choice as their race. 5th edition moves away from this; a character's alignment is now used strictly as a guideline for moral choices, and abilities that used to work off of alignment (such as the paladin's ability to detect evil or the spell Protection from Good) now work off of the type of creature (allowing the paladin to detect undead, fiends, or celestials regardless of his or her alignment). If you want to reflavor or modify certain features to work only on evil undead, that's your prerogative; however, I think that leaving them intact could lead to great moments of worldbuilding as a cleric accidentally turns the city's constable in an attempt to stave off the undead horde.
I am going to suggest a minor rules change.
In the default setting, there is an assumption that almost all undead are evil. That means that abilities that target all undead in an area have a certain utility. However, with the new setting there is a higher chance that the player characters will now need to distinguish between allied and enemy undead. It can happen in the default setting too, just is much less likely.
So I suggest that you make the Cleric's turn undead ability, which is a core class feature, selective - i.e. the player decides which enemies in the area of effect should be targeted. To my mind, that is necessary to re-balance the class in the new setting.
There may be other powers or spells that are affected in a similar way, but probably not worth changing since they are more optional, and not such a core part of the classes involved.
Thematically, it will also make sense that even the good deities will not want to have blanket opposition to all use of undead, if most normal people accept it, whilst retaining the gods' role as arbiters between life and death. You could of course play with this theme and have the churches of good gods opposed to the civic use of undead, but you may find this weakens good religions as a whole in your setting.