The short version of the answer is that a skilled enough necromancer is enough of a perceived threat to the established power structure of the lands they reside in that the leader take action to neutralize that.
Something that should be noted is that it doesn't have to be a militaristic threat. The zombie dreadhorde can most definitely be a militaristic threat. However, an undead horde doing repetitive manual labour can create an economical threat to the established power structure. Learning things that people are not supposed to know is a different kind of threat to the powerful.
Also noted is that it does not have to be an actual threat. Just because a person can raise an army, does not mean that they will. But the fact that they can makes them a potential threat.
The Unnature of Necromancy
Calling all Spirits
People like to focus on the raising undead hordes part of necromancy, and that is all well and good, but there can be so much more to the art of necromancy that is far more benign in principle, but just as dangerous to the powerful.
I like to point out our English definition of necromancy:
a method of divination through alleged communication with the dead;
Source -- Dictionary.com
This could very much involve speaking to the recently deceased to find out things, like what and more importantly who, killed them. While on the surface a good investigative tool, you know it will be banned quick when the aristocracy starts getting caught arranging accidents for their rivals because somebody used this to talk to their victims.
We have magic -- there is no "alleged" in this communication with the dead.
Death Magic
Depending on the setting, necromancy also takes into account spells that use negative energies to weaken or outright kill living things.
When one kills with a knife, there is a highly visible knife wound. There is no ambiguity as to how they died. In fact, that they could get in and murder someone can be itself a message. Poison straddles a middle ground depending on the nature of the poison used in the murder and any overt effects of it. But death magic? Unless it leave a tell-tale sign, there is no wound. Just a body flopping over dead.
Done stealthily enough, say in the middle of the night or while the victim is alone in the woods, and nobody will know if they died from necromantic attack or a heart attack. As an iconic example in recent memory, the Avada Kedavera spell in Harry Potter explicitly leave no mark on its victim.
In a similar vein, if you get a necromancer into enemy territory and blight their crops and cause a famine over the winter, that will have a heck of an effect on people not involved in the wars. It is quite bluntly, a horrible war crime on civilians, at lest by our standards. But the catch might be that such a powerful curse on the land does not dispel easily or may even have unintended consequences.
The Undead Labour Market
When people think of raising undead armies, they think of war. While this can be a good use of human resources, another is in the mindless and repetitive jobs around.
Should the nature of your basic undead allow for it, with a bit of clever machinery a zombie can power basic things or do a simple task without fail or break. It's basically free labour, and that allows the commoners time for themselves to do things that the nobles may not approve of. Also, if it's one man's zombie workforce, then that centralizes economic power in one person. This is possibly a threat to the local administrator of the village.
The Nature of the World
Magical Balance
Note, you have magic in the world. How would the world itself react to an undead army, or more specifically the concentration of negative energies where the undead army is and/or was created? I could see that the biggest problem of the undead hordes not being the undead themselves, but the imbalance in the magical forces of the world caused by concentrating so much negative energy in one location.
For that matter what is the nature of your undead? Various media have different kinds of undead, and even your zombies may have different properties than the general norm. Some of them may not be conducive to the control of a large-scale army of undead.
Societal Balance
It has been brought up before, but the big question here is if this is one world-wide ban in the vein of "I hate you all, but this is the one thing we all can agree on" or if this is each individual kingdom/state making the decision and they happen to all agree necromancy is bad.
Even then, each kingdom will likely have their own reasons for the necromancy ban, as well as ensuring that their neighbours have and are enforcing that ban. There could be kingdom-specific reasons as to why necromancy is banned.
- The kingdom of intrigue bans it because it unbalances the political and diplomatic games the nobles play. That it happens to ban undead armies from ravaging the countryside is a bonus to them
- The kingdom that honours its ancestors bans it to prevent their rest from being disturbed or from noble bodies being used for ignoble purposes. That reverence spreads down the the common folk even if they aren't as dedicated to the honour of their ancestors as the nobles are
- The ambitious kingdom banned it because they remember the one time it happened and nearly destroyed the kingdom. The one castle in the corner of their empire lies in ruins, still somewhat unsafe to enter even after a century or two. They aggressively prevent the art from returning to avoid a repeat of history
- The kingdom with less fertile lands bans necromancy so that nobody can blight each other's lands as a form of revenge. They can't afford the loss of food it could cause over their winters.
The point is that everyone will have their specific reasons to ban the practice even if there is a world congress that has agreed to it on a global level.