Every memorable villain needs a good backstory. Anime villains with compelling backstories end up being just as, if not more so, engaging as their heroic counterparts. Since many anime stories are told through multiple episodes, anime villain backstories receive plenty of fleshing out. It's easier to find Mao from Code Geass a more sympathetic anime villain after learning how another character exploits him.
That said, plenty of backstories fail to make the character's evil actions forgivable, though they might illuminate something else about the character's motives and/or the story's theme. Nothing excuses Monster's Johan Liebert serial killings, but when understand the horrors of his childhood, they at least make a lot more sense. A fleshed-out anime villain gives a movie or a series an added depth. Just because they're bad guys doesn't mean their stories need to be too.
Hiei, a male fire demon, is born into an isolated group of female ice demons. Though ice demons tend to reproduce asexually, resulting in female clones, they are capable of sexual reproduction; his mother's affair with a fire demon resulted in Hiei's birth. In order to maintain the clan's monoculture, they throw the young fire demon off of a mountain at birth. A group of bandits end up saving and raising the young demon, who quickly learned to enjoy committing crimes. He flaunts the valuable Tear Stone his mother left with him, encouraging people to try and steal it so he may lure them to their demise. Hiei loved murder, and his background didn't really excuse that.
But Hiei willingly takes a major hit to his powers by getting the Jagen Eye surgically implanted into his forehead. This eye allows him to find his former village. At first, he just wants to find a jewel he lost in the area, but when he learned of a twin sister who had left the village to search for him, he changed his priorities and decided to look after her. For the first time, Hiei actually cares about another person.
Nearly every villain in Naruto boasts a compelling backstory, but Obito Uchiha's is one of the most powerful.
As a child, Obito lived as a happy-go-lucky kid with a personality similar to Naruto's. When a mission goes terribly wrong and half of his body gets crushed under a rock, his teammates Rin and Kakashi fail to rescue him and leave him for dead. Before doing so, Obito gave Kakashi his eyeball, which contained a powerful ability called the sharingan.
But Obito does not die - his ancestor Madara rescues him, replaces half his body with cloned plant material, and keeps him underground for a year while he recovers from his injuries. All the while, Madara convinces him the rest of the immoral world deserves to be destroyed. Obito doesn't believe him until Madara devises a truly horrifying situation - he implants a tailed beast into Obito's former teammate and crush Rin, then leads Obito to the place where Rin would force Obito's best friend, Kakashi, to kill her and prevent the beast from destroying the village.
Obito doesn't realize Madara manipulated the situation, or that Rin sacrificed herself. He only understands that his best friend murdered his other best friend. Now, he's ready to destroy the world alongside Madara.
#20 on The Best Naruto Characters
Team Rocket consists of Jessie, James, and Meowth, three small-time crooks whose eternal goal is to steal people's Pokémon. You might not expect villains like this to get backstories at all, but all three of them hail from unique backgrounds explaining why they joined Team Rocket and remain a team after all these years.
James came from a wealthy family who showered him with material goods but no individual affection, eventually running away to avoid an arranged marriage. For him, being in Team Rocket allows him the freedom his family never allotted him, along with a chance to rebel against "high society." Meanwhile, Jessie was born to high ranking Team Rocket official, but ended up in foster care when her mother leaves on a mission to find Mew. For her, the criminal organization is her birthright - one she often fails to live up to, just as James does to his. Meowth learned to talk in order to impress a fellow Pokémon, but was rejected as a freak. In Team Rocket, he finds a family who won't reject him no matter what.
Nothing motivates a person to become a villain like being forced to live in an underground crypt their whole life. Malik Ishtar, the favored son of an Egyptian clan, was tasked with guarding a series of holy carvings. During a magical ritual, those carvings cut into Malik's flesh. Aside from the agonizing pain, Marik also watched his father beat his adoptive older brother for basically no reason. Trapped in a terrible situation, Malik grew increasingly angry and resentful.
As a result, he developed a split personality, Yami Marik, and swore revenge on the Pharoah Atem, who he believed responsible for driving his family underground in the first place. He murders his father, escapes the underground crypt, and sets about getting revenge on the Pharaoh, whose spirit lives on in the body of a teenage boy named Yugi Muto.