Haldir only appears in the second book (TT). He is one of the elves set to guard the northern bounds of Lothlorien. He guides the Fellowship to Caras Galadhon and, from what I can tell, that is the extent of his role in the book.
I see two reasons for Peter Jackson to kill off Haldir, one is purely pragmatic, the other symbolic. Let’s start with the pragmatic reason. The elves never go to Helm’s Deep in the book. In the film, notice that apparently no elves survive. From the point of Haldir’s death, or the retreat to the Hornburg, we never see another elf besides Legolas. So the reason for Haldir’s death is simple: to avoid all the problems that come with changing the plot. How would Jackson have been able to explain away an army of elves? He couldn’t, because they don’t work, they are totally alien to the plot of the book. So he kills them off.
Ok, well that theory seems a bit cold hearted and depressing! So let’s look at the possible symbolism of Haldir’s and the elves’ deaths. What better way is there to show resolve and loyalty than to sacrifice oneself for another? The elve’s sacrifice demonstrates their resolve to fight evil. It also reinforces their “allegience” with men. Also, it increases the tension and gravity of the scene. The elves are stronger, faster, better armored, better armed and better trained than men. They are an army. If they cannot survive the onslaught of the Uruk-hai, how can the men of Rohan expect to?
Ok, so those are my reasons why Haldir and the elves would die. Now let me explain why the elves coming to Helm’s Deep in the first place is a horrendous idea. The Last Alliance is called “last” for a reason! Also, recall that Lothlorien is attacked three times during the War of the Ring. Lothlorien would have fallen if troops left to help Rohan. Remember, the elves are dwindling, both in numbers and power. It is hard to believe they’d send troops to aid men when they themselves are greatly threatened.
ALSO, and this is my biggest point, the elves coming to Helm’s Deep decreases the valour and courage of MEN. The end of the Third age acts as the transition point between the time of Elves/Dwarves, and the time of Men. At Helm’s Deep, we feel the true desperation of being alone in a field of enemies, pitted against foes beyond our strength. And yet, the Rohirrim harden their hearts against fear, to fight on. It is crucial that the defenders be MEN, not Elves. Elves are associated with the mythical, divine, supernatural. It lessens the tension and fear, because their prowess seems so great. In the book, the presence of the Heroic is easier seen: Theoden’s ride, Aragorn, Eomer, Gimli, Legolas…they all stand above the rest. In the film, they are set within an army of elves…much their equals (or betters, if they retain the skills seen in the Last Alliance). To me, it just doesn’t work at all. It ruins the tone and fear of the moment. It ruins the final eucatastrophe of the coming of Erkenbrand and Gandalf.