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! tormented 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 slays hundreds of people, eventually betraying a person he loves in one of the most egregious ways possible.
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.
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 one of the most disgusting ways possible.
Guts often uses his formidable strength to save others from various dangers including despotic power-hungry priests to literal demons, but his rap sheet is long and horrible. First of all, he slays hundreds, if not thousands, of people, including children, under a staggering variety of circumstances. Though he doesn't enjoy it, he'll do it out of necessity, and in the world of Berserk, necessity is often observed.
Though technically a hero, Guts will unleash his cruelty on the ones he loves. One of the worst things he ever does is sexually assault 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 ever erases what he's done.
Lelouch Lamperouge's ultimate goal involves taking down the Holy Britannian Empire and freeing the Japanese people from its tyranny. To do this, he must take out a lot of people. None of the slayings are exactly good, but one of the saddest is when he must end the life of 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 Britannia. However, Lelouch accidentally uses his Geass power to set her on a path which would end in the Japanese people being slain en masse.
The only way to prevent that outcome is to end 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 sets her on the wrong path through mind control.
Koyomi Araragi is a complicated dude. Even if he barely knows a person, Koyomi will happily go through absurd amounts of physical and emotional trauma to assist them. However, that hardly makes up for some of his seriously inappropriate acts, and he needs to be taken to task for them.
In Bakemonogatari, he repeatedly gropes, only to start physical fights, with an elementary school student named Mayoi. The fact that Mayoi is actually an Oddity doesn't make it any better - she still has the appearance and demeanor of a little girl, and Koyomi initiates these assaults before he knows anything about her. In Nisemonogatari, he holds his sister down and... erotically brushes her teeth? As has already been said, Koyomi is complicated.