It's an unhappy ending if good does not triumph over evil.
Books and movies with unhappy endings are generally frowned upon, they tend to do poorly commercially. The successes amongst unhappy endings tend to be highly emotional, understandable cautionary tales; which means in a twisted way good still triumphs over evil, or at least evil leads somebody to a terrible end. The reader is following along with a character they like that descends into drug addiction, or crime, or losing their marriage, or corruption, etc, but they end up miserable or dead in the process.
The Escape Hatch ... Flip The Script
AKA role reversal. The villain proves to the MC that the MC has been duped, that he is a pawn of the people he thinks he is helping, or his management, etc. The villain doesn't convince the MC to be evil, the villain convinces the MC he has been working toward evil ends and the villain is doing good.
And instead of insisting the MC change sides, the villain gives him a chance to verify all this himself. After telling him all this, the villain, with the MC bound and a knife to his neck, says "I could kill you, and eliminate a threat. Remember that. But I won't, because I don't think you are evil. I'm going to set you free. Come back when you're ready to fight for what's right."
The reader following the MC is not disappointed, the twist does not mean the MC is now fighting on the side of evil. It means that the reader, like the MC, was duped into believing the villain was evil, but now understands the villain was good and the real villain is the queen that sent the MC out in the first place, trying to get rid of him so she can kill her husband and take power.
But the villain didn't kill the MC as she expected, the villain just pulled back the curtain to expose the queen as the real villain all along, and now the reader can believe the MC is still fighting for good, and the defeat of the queen represents the triumph of good over evil, so this is a happy ending.
Another Escape Hatch: Double Reversal.
A double reverse means the protagonist succumbs to the temptations of evil, but the "good" inside him eventually reasserts itself, and he reverse again: To the side of good, and defeats the villain after all.
Falling for the villain's talk is just another obstacle and failure along the way, this time within himself. You have a flawed protagonist. The next story is not exactly your situation, but consider a good cop. In a time of incredible financial hardship (e.g. he can't pay for the treatment his wife/mother/kid needs) he becomes a dirty cop. He gets deeper and deeper into being a dirty cop, until he accidentally shoots and kills an innocent witness he was trying to keep from exposing him. He covers that up successfully, but it weighs on him so much, he sacrifices himself in a blaze of glory to become, once again, a good cop.
Evil Triumphs In The End is not generally a story people like. It is depressing, and we read fiction to escape the real world, where evil often does triumph in the end, criminals and murderers and rapists and frauds get away with their predations, get insanely wealthy and/or powerful, and are never punished, dying peacefully in their sleep without a regret in the world.
You can write it if you want, perhaps it will be some kind of catharsis, but if your goal is to entertain people and have them like your story, then I'd suggest evil can be wildly successful in your story, but in the end, good must triumph over evil.