For a genre often associated with beloved heroes like Sailor Moon or Goku, anime often makes their protagonists commit horrible atrocities. Unlike anime that follow villains, anime with complicated heroes do not necessarily set out to create sympathetic characters; some of these "heroes" are just not great people. Some anime heroes who did something bad have one or two minor transgressions on their rap sheet. Joey Wheeler of Yu-Gi-Oh! bullied Yugi for about two episodes, but he gets his act together and becomes a good friend. Other morally ambiguous anime good guys commit more serious misdeeds, ones that can be hard to overlook. Guts of Berserk kills hundreds of people, eventually betraying a person he loves in one of the most egregious ways a person can.
Anime protagonists who do terrible things can sometimes be hard to root for, but sometimes their actions serve to tell something larger about the storyline. However, that only provides justification for a few of these immoral anime heroes.
Lelouch Lamperouge's ultimate goal involves taking down the Holy Brittanian Empire and freeing the Japanese people from its tyranny. To do this, he must kill a lot of people. None of the murders are exactly good, but one of the saddest is when he must kill Euphemia, his half-sister. Despite being part of the royal family, Euphemia supports the Japanese people and wants to create a safe zone where they may live without being oppressed by Brittania. However, Lelouch accidentally uses his Geass power to set her on a path which would end in the Japanese people being killed en masse.
The only way to prevent that outcome is to kill her, so he does exactly that. It's a particularly tragic moment, because Euphemia wants to do the right thing, and Lelouch is the one who accidentally set her on the wrong path through mind control.
Guts often uses his formidable strength to save others from various dangers including despotic power-hungry priests to literal demon attacks, but his rap sheet is long and horrible. First of all, he kills hundreds, if not thousands, of people, including children, under a staggering variety of circumstances. Though he doesn't enjoy killing, he'll do it out of necessity, and in the world of Berserk, necessity is often observed.
Though technically a hero, Guts unfortunately will unleash his cruelty on the ones he loves. One of the worst things he ever does iswhen he sexually assaults Casca, the love of his life. Thanks to traumatic events, including repeated rapes, Casca's mind is already nearly destroyed, and she can no longer speak, reason, or look after herself. Though Guts wants desperately to protect her, he still assaults her. He immediately begins feeling remorse and self-loathing, but nothing it never erases what he does.
No matter how nuanced and well-developed Shinji Ikari becomes over the course of Evangelion, it's hard to overlook the moment he pleasures himself over Asuka's comatose body. Yes, you read that right; meek, little Shinji actually does that. Though he's motivated less by total depravity and more by profound loneliness and desperation, he still totally disrespects his friend in the most disgusting way possible.
Itachi Uchiha's crimes are simultaneously the most reprehensible and the most understandable in all of Naruto. He murders every single member of the Uchiha plan except for his younger brother Sasuke, then uses genjutsu to force Sasuke to re-watch every moment of the slaughter that he'd missed. He tells the eight-year-old that he did it to test his own abilities, and for most of the series, that remains the only explanation.
Later in the series, it is eventually revealed the city government manipulated Itachi into killing his family. The government says Itachi must kill them all (except Sasuke) or else they will come and mow down his family themselves. For a 13-year-old boy who already suffered PTSD thanks to a war-torn childhood, Itachi isn't exactly in a state to refuse, or even understand his actions. He commits terrible crimes, but the reasoning behind them makes it difficult to hold it against him.