Biography
Usually when someone dies in fiction, their body is ignored. If they're important (or just important to the plot), you may see them being buried or inspected at a local morgue, but due to the Law of Conservation of Detail, they are usually quickly forgotten. Sometimes, though, the deceased gets a lot more attention.
Sometimes a character has a pragmatic reason to kill a dead person again, or is too emotional to stop themselves even though their victim is long past resistance. In this case, however, a character makes a deliberate decision to humiliate or punish the dead person even further. Sometimes they're so angry that death just isn't enough, sometimes they need a Dead Guy on Display to show the public that an enemy is truly, thoroughly defeated, and sometimes they're so evil they want to play with them some more. Spite, revenge, intimidation, and depravity are common motivators for desecrating the dead — for both Heroes and Villains.
It isn't always the physical corpse that's being desecrated; the spirit of the victim can be targeted for further abuse, a grave or monument can be defaced, or the works of the person can be destroyed even if they could be utilized for the betterment of society because it's more important to erase the creator.
The message sent is often dependent on what kind of character does the desecration:
Villains and Villain Protagonists:
It's usually done For the Evulz, and either where they cross the Moral Event Horizon, or if they have already crossed it, to prove just how depraved they are.
Affably Evil, Wicked Cultured, and Noble Demons usually avoid this whenever possible because Even Evil Has Standards, so desecrating the dead may point to a Complete Monster.
It's more common as a threat than as an actual action, both because the villains usually lose or die before they have the hero's corpse to play with and because it's an easy way to show their depravity without actually having to show anything.
Heroes:
Usually an Asshole Victim because the dead villain really deserved it, or a case of Pay Evil unto Evil. If it's a Dead Guy on Display, it may simply be to raise morale.
If not, it's likely a morally gray moment or sign of an approaching If You Kill Him, You Will Be Just Like Him!-type Moral Event Horizon. To keep them heroic, they can be disturbed by their own actions and look for a way to make up for it.
May be a sign of Sanity Slippage or morality slippage if they've been pushed into it by a villain's torment or goading.
Antiheroes / Antivillains:
Often exists to prove to the audience that they really deserve their darker reputations.
They may be the Psycho Supporter, doing what they feel has to be done but the morally purer characters can't.
Any of the above:
Sometimes, you want to Make Sure He's Dead for perfectly sensible, pragmatic reasons — if your foe has a Healing Factor, Super-Toughness, or any other ability or talent that might assist with Faking the Dead, it's better to be safe than sorry.
Like any other blatantly obnoxious action, it may be intended to provoke someone (probably the deceased's friends and/or loved ones) into losing their temper and doing something foolish.
Compare this to Kick Them While They're Down (where the victim is usually still alive), Of Corpse He's Alive (where the corpse is used as a puppet to maintain a pretense that the deceased is alive), and There's No Kill like Overkill (in which the death itself is the abuse).
May overlap with What the Hell, Hero? (if the good guys do this and are called out on it), Creepy Souvenir (when a part of the corpse is kept as a trophy), Dead Guy on Display (when the corpse is displayed publicly, whether mistreated or not), or Last Disrespects (when the abuse happens at the funeral). Eating bits of someone's corpse is a particularly nasty way to desecrate their body: in places which don't have laws specifically forbidding cannibalism, cannibals are tried under desecration of a body. An extremely mild version of corpse abuse might be the Spiteful Spit. Human Resources is when someone extracts something useful from a body — which can overlap with this trope.
Supertrope to Pummeling the Corpse (when a person can't stop beating someone they've already killed because of an emotional breakdown), Make Sure He's Dead (which is the justified version, and which may overlap with Rasputinian Death in cases where the dead has to be desecrated to keep them that way), and Poking Dead Things with a Stick (discovering a dead body or animal and poking it with a stick to check if it's still alive). Compare Dead Guy Puppet.
Robbing the Dead is almost never considered this in fiction, although it is in Real Life. The Hero has to loot the bodies and the crypts, after all.
Contrast Due to the Dead. When one person's Due to the Dead is another's desecrating the dead, it's Freaky Funeral Forms.