Even when the bad guy wins it's usually supposed to be a moral victory for the good guy.
Now there are a lot of movies where the good guy is partly anti-hero, which means he's not really that good a guy. Easy Rider, Taxi Driver, Raging Bull, and many many more have lead characters like that.
Side note: Robert Redford intentionally has never played a bad guy or anti-hero. Most actors have done both.