In the third season of the legend of korra, a group of people try to get rid of a monarchy (which is long established as especially unequal and oppressive) in favor of self government. They also try to get rid of the avatar, because she is an infallible being with incredibly outsized power. I love the avatar universe and get how they needed to fight them, but the group wasn’t wrong
Rose is trying to move the country off of fossil fuels and onto sustainable green energy. Somehow Gamefreak manages to portray this as being a terrorist and extremist. How dare he try to move Galar away from coal?
Voyager kinda fucks with my ability to set spoiler tags, so here is your Spoiler Warning.
The Cabin in the Woods (even tho the organisation is run by complete assholes, they also happen to postpone the end of the word)
Mass Effect series (the Geth are actually ok having peace with everyone. They just happen to be in a civil war with Reaper worshippers)
Witcher 2 (Letho turns out to be the good guy)
Wanted (the father turns out to be the good guy)
Battlestar Galactica 2004 series (yes, the Cylons enacted the nuclear holocaust on humanity, but there is a case to be made that the vast majority of them have been manipulated by a faction of ancient Cylons, which leads to a civil war later in the show)
!handsome jack started off as an honorable person with morals, but was repeatedly stabbed in the back and jaded over time. He still has the mindset of a good guy but the chaotic planning of a bad guy due to the experiences that he's had.!<
The French version of La Femme Nikita, although it's more of a redemption arc than "villain turning out to be a good guy." She starts out as a junkie petty crook who murders a cop in cold blood, spends most of the film assassinating people for the government, and in the end seems to have gotten her life together.
Assuming you're counting stories where the villain did very bad things for the purpose of a doing something good, there is an anime from 2005 called Speed Grapher.
The Sixth Day, one of Arnold Schwarzenegger's please-take-me-seriously projects, is possibly the wrongest it is possible to be about whether clones are people. Still a fun movie. Just ass-backwards in its motivation. I'm not sure how much of its moral grey area was intended by the script or the direction. The anti-clone "good guys" are pretty terrorist-coded. Arnie's just caught up in the middle of their guerrilla fight against a generic corporate bad guy. Who solved death. How terrible.
Off-topic Schwarzenegger faff: End Of Days is dumb. Jingle All The Way is the most 90s Christmas movie possible. Eraser is a slick action movie that somehow has no cultural cachet outside of every video game with a railgun.
Sousuke Aizen used deplorable methods in his attempt to achieve godhood and conquer the "empty throne of god", but was ultimately justified when the forces of Yhwach, the legitimate son of God decided to invade and lay waste to the Soul Society. Subverted yet again when it is revealed that the current "Soul King" (the lynchpin that hold reality together and the pretend-ruler of the world) is in fact an empty husk of the original God, who was assassinated by the Shinigami because they feared his powers, and Yhwach's bloody conquest was in fact an attempt at revenge. Some of his final words before dying are "I will create a world without the fear of death".
Interview With a Vampire ... kind of ... Lestat was by no means good to Louis, but their portrayals in the rest of the series was quite different ... I think that Anne Rice was trying to show that neither of them should be considered reliable narrators and Louis will always try to portray his situation as awfully as possible and Lestat is a narcissist and will always try to portray himself in the best light even when acknowledging what he did incorrectly.
But, when I saw that book 2 was about Lestat, I was like ... wtf ... I hate this guy, why would I want a story with him as the main character and then I read them all, lol.
...so the (racist af) Tsukimichi series/manga/webnovel has this Demon race, right? Whole isekai happens because they instigate a war against the h(y)umans outta nowhere and the Goddess needs a hero.
spoiler
Well~ turns out these mofos had it comin'... and so does the Goddess. 🤷🏿♂️
it only sorta works for this post since the main character is quite indifferent to the conflict war for quite awhile
interestingly, the story primes you up for that reveal with a precursor villain of sorts
spoiler
Lime and his cohort are quite villainous until you learn what brought that fate upon the Rembrandt family 😐