Morality is obviously a major issue in fiction. This is especially true in fantasy and sci-fi, perhaps because of both genres’ roots in medieval romance and classical epics. It also sells well, after all the question of good versus evil is an old and powerful story. It is so old that way back, authors could easily portray simple morality in their work and audiences would go with it. More recently, perhaps around the 1960s or 1970s, portraying simple black & white morality became less common, or more difficult. A more refined range, sense, approach to morality became the standard.
The moral continuum, greyscale morality, moral relativity, whatever, is both a boon and burden for both genres. On one hand, I think the genres, particularly fantasy, have become more realistic since embracing the continuum view. Sci-fi has been using the continuum for a variety of purposes for decades, especially in the cyberpunk and socio-SF subgenres/approaches. However, embracing the continuum view could be tied to various book banning attempts.
Sticking with the fantasy genre, several examples come to mind:
Tolkien and C.S. Lewis tend toward the black and white morality, whether elves v. orcs or Aslan (Christ) v. evil. This is comforting, easy, and simple. The good guys and bad guys are obvious and clear cut.
Fritz Leiber & Robert Howard, on the other hand, both contemporary to Tolkien throw the binary out the window. They wrote largely amoral figures who focused more on greed, desire, and the adrenaline rush than on such philosophical concerns as good & evil.
Michael Moorcock effectively tried to side step the morality issue in his entire body of Eternal Champion books. Instead, he shifted the issue to law vs. chaos, with balance being the greater good throughout.
George R.R. Martin and J.K. Rowling become two of the clearer greyscale moral continuum writers. As some have pointed on in the interwebs, there are really no truly good and few truly evil characters in his series. Rather, there are a lot of shades of grey (certainly more than 50 of them), with everyone effectively morally compromised to some degree, even Ned Stark. Rowling does this as well. She tends, like Marvel Comics, to create her greyness through relating personal histories. That is, her “bad guys” are understandable: Voldemort had his orphan years with a deadbeat Muggle dad and discovered his pureblood maternal line; Greyback became the monster that society believed him to be; the Malfoys play at “evil” to fit in with their social class, or what they believe to be fitting in. For the Marvel mention: Magneto/Eric is completely understandable – the holocaust survivor who has sworn to never let genocide happen again, regardless of the cost (if his methods were a bit different, he’d be a hero).
Personally, the moral continuum makes for more interesting characters and story. But, it does run afoul of the self-proclaimed morality police of the real world, who want things simplistic and easy (won’t get into a rant about that here). To refer to Terry Pratchett, he once said that he had qualms about Tolkien. He never trusted the elves (everyone said they were good, and we were supposed to buy that even though we never see them really being good) and always thought it problematic that there was no chance of redemption for the orcs, simply because they were orcs. In our reality, and maybe this is something modern readers want to see more of, there are bad elves and good orcs all around us, the good guys don’t always wear white hats (Luke Skywalker) and the bad guys don’t always wear black (imperial stormtroopers).