Many have heard tales of how people have seen the dead move. An anecdote about a dead uncle's fingers moving after he died. And there are roots in pop culture and folklore: zombies awakening, vampires, the supernatural awakening the dead.
Nerves
The anecdote about fingers moving after death, at least, has a scientific explanation. After death, we move our muscles as a result of an electrochemical reaction in our nerves.
The chemicals that cause this reaction are stored in our nerve endings, and when we die, they're gradually released. Usually, though, the resulting movement is just a twitch.
For example, even though it's rare, you might see the deceased clenching his or her fingers, or notice his or her leg jerk a little. In the end, it's just a chemical reaction.
Head Turning, Groaning
Many years ago, even more gruesome movements were made by the dead. In the days before embalming, gasses would build up within a corpse's tissue as a result of the decomposition process.
When these gases escaped, you sometimes saw the deceased turning his or her head or shifting an arm or a leg. And sometimes the escaping air would move past the vocal cords and make it seem as if the corpse was groaning. Some people have also tied these movements into people's beliefs about vampires.
Read More:
Conway, Samuel, "Twitches in dead people."