Violence is a sticky sort of thing when it comes to writing. It's easy to go overboard. On the other hand, violent deaths can serve an important purpose in your story. The trick is knowing why the bodies exist and asking yourself if they're really necessary. Here's a list of reasons that I think are totally valid for tossing in a corpse.
1: Plot. How many murder mysteries have you read where nobody died a violent death? ....that's what I thought. Case closed.
2: Revealing Character: Violence is Hollywood's favorite way to show that your villain is pure evil. Remember The Empire Strikes Back where Darth Vader was dropping 'em like flies?
Violent deaths can serve to characterize your heroes, too. I'm thinking of Jack Sparrow's first appearance in Pirates of the Caribbean: The Black Pearl where he takes his hat off while sailing past the dead pirates. That moment helps humanize him. He has a respect for the dead (perhaps more so than the townsfolk who were willing to use bodies as warning posts). He also has a sense that those dead guys could be him if he got caught. It reveals his desperation: he's willing to sail into town despite the warning. That's a lot of characterization for one shot of a guy taking off his hat.
3: Establishing Setting: Speaking of those hanged men in Curse of the Black Pearl, the scene does more than build Jack Sparrow's personality, it also tells you a lot about the time and place of the story. This is the sort of world where it's normal to leave the bodies of criminals out as a warning.
The circumstances where violence is considered appropriate tells you a ton about the setting of a story. In The Three Musketeers, nobody cries `wait! Dueling is crazy! Surely there must be a better way to settle your arguments than drawn swords!'
4: Shock Value: When used right, the shock value of violence can add a lot to a story. Of course, for shock value to work, the event must be shocking. That means gore on top of gore is out because it lessens the shock value. Also, shock value changes depending on the setting. What's shocking in an Edwardian drawing room may be normal in a back alley at the height of the French Revolution.
The value of shocking your audience is added suspense. In the movie Serenity, an important character dies, and it is genuinely shocking. Not because the death is unusually violent (it's a random accident) but because the death is that of a major character. Up to that point in the movie I figured I pretty much knew the end. The good guys win, they fly off into the sunset, the end. But after a major character died, I no longer knew how things were going to turn out. When the final confrontation came, I was bracing myself for tragedy.
As readers and moviegoers, we've gotten used to the idea that certain characters are safe because they're too important to die. Shock Value violence is a way to shake people out of that confidence so they can enjoy a story with the same roller-coaster suspense they had before they learned to predict who lives and who dies. It allows you to get the same thrill from stories you had as a kid.
And that's it: the uses of violence in storytelling. There may be some uses I didn't think of, and naturally my list is completely subjective. Any thoughts?