Nobody really knows why Bowser kept kidnapping Princess Peach of the Mushroom Kingdom . It didn’t matter. All that mattered was that a giant turtle was up to no good and that meant that he and his kids were going to get got, because that’s how the Mario Brothers roll. But despite stomping on dozens of foot soldiers and chucking the guy’s progeny into lava pits, it was a given that Mario and Luigi were good guys. They freed the Mushroom Kingdom from Bowser’s minions time after time without making any demands of the people and when the dust settled they were not above meeting up with old adversaries at the Kart track for some friendly racing.
In those days the heroes were pure as the driven snow and even a game like Doom , which was a bloody and brutal affair by the standards of the time, put you in the shoes of a soldier fighting demons. No ambiguity there, for all the machismo and aggression your character was saving the world, not just from scary monsters, but scary monsters from Hell, the worst kind of scary monster.
So how do we get from the video game hero as a sort of chivalric knight figure to a character who carries out a terrorist attack in an airport  or who tortures people  or who turns up in a country and completely trashes the place at the behest of a foreign power ? Perhaps it is a desire for grittiness and edginess, perhaps it’s an appeal to jingoism, or perhaps it’s just writers within an immature medium misunderstanding of the role of a hero in a story.
There are plenty of games of course where being bad is good, where you are attacking the world order rather than seeking to protect or restore it. The Grand Theft Auto series has always cast you as a deadly outlaw, the God Of War series sees you play as Kratos, a brutal monster in his own right. These characters are bad guys, but they are generally painted as having some virtues which are considered universal and which set them above the villains of the piece, such as loyalty or a sense of purpose. In these games it is the world that is portrayed as the villain more than the villainous protagonist. There is a conscious effort to present the world in these games as corrupt.
There are in effect three sorts of video game heroes, the heroic ones, the anti-heroic ones, and those where it is the player who is in charge. Developers and writers of the first type in particular need to be careful, because if they cast a character as a hero and he comes across as a scumbag, a douchebro, an idiot, or worse yet all three  then that’s bad writing. That’s a hero who makes you feel unclean for walking in his shoes. Some games approach this knowingly, such as Far Cry 3  or Spec Ops: The Line , where the main character is forced to confront his own misdeeds, but for others it is a consequence of bad writing. Any hero who makes you root for the guys you are shooting has failed.
The interesting thing with these failed heroes is how they come to fail in the first place. For example you don’t need to have a hero commit torture when you are writing the story when you can just have the hero find what he needs some other way. Somebody, for whatever reason, chose that route for the character. By the normal run of things it would be considered insulting to portray British or American government operatives torturing people in such a casual and practiced manner, but on that front it isn’t only the ethics of video game characters to have slipped in the last decade or so.
Games where you are in essence playing through a story on rails are subject to the control of writers but it is games where you are free to carve your own path where some of the strangest ethics in games can be seen.
For example, nearly every fantasy RPG features crazy amounts of looting. There you are, in Skyrim , or Ferelden , or Azeroth , or Faerûn  and the first thing you do upon slaughtering an enemy is to rifle his pockets for coins, gems and other items. Needs must and all that but really it seems odd that nobody passes comment on a rich warrior hero, the would-be saviour of the world, rummaging around in a decapitated goblin’s loincloth for his beer money.
This is coupled to the fact that in games of this nature there is usually a sense that anybody and anything outside of a town is fair game to be murdered and to have their possessions claimed by the noble hero. Skyrim handles this in a very crude manner; if a person is to be considered fair play to be murdered then they will be called a "Bandit". They have no name and are thus freely killable. This is a strange feature in a game that otherwise does such a fine job of making the world feel alive, but it is one mirrored in many other role playing games where faceless goons pad out the world in lieu of characters.
Games that rely upon experience points for advancement are perhaps the worst offenders when it comes to the ethics the player is encouraged to show. The crudest interpretations of experience points based systems literally entail a path to progress and success that is paved with the bodies of whatever hapless individuals happen to cross your path. You want to be a better cleric? Kill some people. You want to be able to learn more spells? Set fire to a few dozen wolves. The world of the fantasy RPG is staggeringly predatory, although one might argue that’s the point.
In games where there is true freedom of choice you will usually find that the easy path is the unethical one, whether this means just stealing everything that isn’t nailed down from everybody and selling it on, or shaking people down for greater rewards when you’ve helped them out. But there can be a certain satisfaction in not taking the path of least resistance. In the same way that a player might want to keep the difficulty setting on high, they might also want to play by a code.
In games with a predestined story it could be said that there is something more realistic and more grounded about a hero who is willing to get his hands dirty, or to put it another way, betray the principles he claims to represent. However what games developers need to remember is that games are not films. Watching a hero on screen betraying his ethics is one thing, but if you want players to stay invested in the character as their avatar, as their hero, then those sorts of situations need to offer a choice.
When a game offers you nothing but scripted sequences of unpleasant people killing each other, with nobody to root for and nothing to hold your attention except the next action set piece, it is barely any better than a movie.