I planned a book that's on hold, about a antisocial deliequent(Protagonist) who helps an innocent boy(Deutagonist) solve the murder of the delenquent's best friend who confessed to the another guy, but during that 6 yanderes (A person who is both highly affectionate and dangerously obsessive concerning their love interest.) While most of the yanderes and the protagonist (the expectation of 1) are portrayed as sympathetic but most of the stuff they do is fucked up ranging from bullying, stalking, kidnapping, and murder. Even the protagonist manipulates and harms people to protect the deutagonist
And while the yanderes and the MC have sad pasts I don't want it to completely justify or even romanticize their actions
This is kind of tricky, and I don’t have a lot of experience with this, but I think it would help if you make characters within the story not condone their actions. Show how they hurt others and focus on that. Show how others don’t care that whoever did these bad things had a bad past and they still hate them and believe a bad past is no excuse. But knowing the backstory does add slight sympathy for the reader.
Excuse my fangirl rant but
I've seen this done excellently twice before. The first time was with Darth Maul in Star Wars. We see him kill beloved characters onscreen and generally just be awful, but it still hurts to see him be driven to insanity and have his brother die in his arms. By the time that Star Wars Rebels comes around, he's insane again and has lost everything but his undying hatred for Obi-Wan Kenobi. And when he finds Obi-Wan, you get the feeling that he's just looking for him so Obi-Wan will kill him. He's a horrible person, but you still feel bad for him because you get a glimpse into how he works, and you see his fall from being a feared, respected Sith lord and crime boss to being an old wreck of a man trapped in a temple with no escape. And while you feel bad for him, it doesn't excuse him killing Satine, Qui-Gon, and a literal village of people.
The other was Queen Levana of The Lunar Chronicles. In her backstory in Fairest, we see that she's a lonely girl being abused by her older sister and you feel bad for her, but her fall to villainy makes her irredeemable, with what she does to Evret, Selene, and Winter.
I agree with @BecInMYday. I think it's important to have the characters around them describe their short comings for you, so the reader can stay engaged with the main character but still keep a good moral compass. I've read books that didn't do this, and after reading I felt kind of.. dirty? Like I'd agreed with things I'd never do in real life because I'd followed along with a dark protagonist.