In the Harry Potter series, there are several ghosts at Hogwarts. They all seem to have interesting back stories. The story of Nearly Headless Nick was explained early on in the series, but I don't recall what the back story is for the Bloody Baron. Namely, why is he bloody?
From http://en.wikipedia.org/wiki/Hogwarts_staff#The_Bloody_Baron (quote heavily edited for clarity and formatting):
The Baron's nickname comes from the fact that he is covered with blood, which appears silvery on his ghostly form. ... This is explained in "Harry Potter and the Deathly Hallows", when Helena Ravenclaw's ghost [Helena was Rowena Ravenclaw's daughter - and her ghost was the Grey Lady of the Ravenclaw house - DVK] tells Harry that the Baron had been in love with her when the two were alive.
When Helena ran off with her mother's diadem, Rowena Ravenclaw sent the Baron after her, knowing he would not stop until Helena was found. When Helena refused to return with him, however, the Baron killed her in a fit of rage, and then, in remorse, killed himself with the same weapon. He has thus haunted Hogwarts ever since, wearing his ghostly chains as a form of penitence.
A more link-heavy but essentially identical explanation can be found on Harry Potter Wikia
Also, HP Wikia's list of deaths in HP Universe lists these events as being "Early 11th century".
Out-of-universe, I don't think he was based on any historical characters (like some other ghosts that were listed in the Headless Hunt) - the only known historical character known as the "Bloody Baron" was Roman Ungern von Sternberg who really didn't fit whatsoever.
Significant unexplained detail: for some reason, Peeves the poltergeist is afraid/respectful of only one creature, that being the Bloody Baron. Never explained in-Universe.
Also, as far as fan speculation, there are two additional theories, neither of them confirmed and most likely both false:
That he was the original user of Horcruxes. Supposedly somewhere it's mentioned that there were two of them (the other one of course being Tom Riddle).
UPDATE: This theory was disproved by J. K. Rowling. An ancient Greek wizard Herpo the Foul was the inventor of Horcruxes.
That the color of blood on his cloths (silver) - which matches the silver color of unicorn blood - signifies that he drank Unicorn blood (see Satanicpuppy's answer below - I reposted it here since his answer didn't have the logic behind the theory). However, Baron intentionally killed himself, so this theory holds very little water and the color match is most likely merely a result of overall color palette of ghosts in the movie.
The Bloody Baron's story is intertwined with the Ravenclaws'. Rowena Ravenclaw, founder of Ravenclaw House, had a diadem of great power. Helena Ravenclaw, the Gray Lady and Ravenclaw's House ghost, stole the diadem from her mother and hid. On Rowena's deathbed, she charged the Bloody Baron, who had feelings for Helena, with finding and bringing her back, but when Helena refused to return with the Baron, he killed her. Struck with remorse for this deed, he then killed himself. Apparently that took several stabs and a long time, which Helena thinks is only right.
This is all explained very quickly in Book 7, The Deathly Hallows, while Harry is trying to find this diadem before the Battle of Hogwarts. Many of the details are skipped altogether in the movie. It turns out that Helena, as the Gray Lady, was persuaded by Tom Riddle while he was at school to divulge where she hid the diadem. Tom found it and brought it back to Hogwarts as a Horcrux, and hid it in the Room of Requirement.
Helena Ravenclaw, also known as the Gray Lady, tells Harry the story of the Bloody Baron at the end of Deathly Hallows:
"Then my mother fell ill — fatally ill. In spite of my perfidy, she was desperate to see me one more time. She sent a man who had long loved me, though I spurned his advances, to find me. She knew that he would not rest until he had done so."
Harry waited. She drew a deep breath and threw back her head.
"He tracked me to the forest where I was hiding. When I refused to return with him, he became violent. The Baron was always a hot-tempered man. Furious at my refusal, jealous of my freedom, he stabbed me."
"The Baron? You mean –?"
"The Bloody Baron, yes," said the Grey Lady, and she lifted aside the cloak she wore to reveal a single dark wound in her white chest. "When he saw what he had done, he was overcome with remorse. He took the weapon that had claimed my life, and used it to kill himself. All these centuries later, he wears his chains as an act of penitence... as he should," she added bitterly.
In other words, he is bloody because he stabbed himself to death.