Something of a plot hole created in the movies that isn't a problem as it is in the book, although the explanation that they fulfilled their duties of defending Gondor seems to be "good enough"
The green ghosts of the movie were actually killing enemies, whereas in the book they offer no true physical threat (which is why Legolas is not afraid, because he's basically not an idiot), but are so terrifying that they drive away the enemies by fear of sight alone (think of ?scared to death?, only literally in some cases here).
Of course Aragorn wasn't only accompanied by Gimili and Legolas like in the movie, they're accompanied by the Grey Company, a group of elves (Elrond?s two sons) and dunedain (guys like Aragorn) and other men - basically the most badass fighting force you could hope for - they're the ones that actually meet up to fight in the Battle of the Pelennor Fields, not the green instant kill quick fix of the movie.
So Aragorn liberates parts of Gondor freeing up a lot of men to go to defend Minas Tirith and makes it to the ships and uses the undead to drive off the forces and capture a bunch of ships for he and the Grey Company to sail in on.
Basically what I understood is that the undead couldn't provide any physical help and in an actual battle situation they'd be pretty much useless, instead they were useful because they were capable of driving off crucial Mordor forces by fear alone before they could go and meet up and attack Minas Tirith.
Instead of receiving reinforcements, the forces attacking Minas Tirith were flanked by Aragorn and the Grey Company as well as liberated forces that had been withheld from going to defend Minas Tirith in order to defend other parts of Gondor that had also been under siege.
But with the movie they obviously had time constraints and showing an unstoppable killing green cloud of ghosts seemed to be the best course of action to keep the movie under 6 hours
