Digging up decaying corpses from the ground, violating the sanctity of the deceased, and risking incurring curses and divine wrath, just so they can stand guard at the gates, patrol the streets, or march on an enemy fortress – is not only inhumane but also not very practical.
1) They are just cannon fodder in case of war, serving to reduce casualties among the population.
2) They have a demoralizing effect on the enemy, which is quite logical.