Comic books have sometimes been decades ahead of the curve on issues of race, gender and sexuality – and they’ve taught Hollywood a thing or two, writes Natalie Haynes.

When the Blu-ray edition of Avengers: Age of Ultron fell through my letterbox last week, the cover showed Captain America, Thor, Iron Man and the Hulk emblazoned across the middle of the box. Beneath them, somewhat smaller, are Hawkeye, Black Widow and Nick Fury. Hovering in the sky above them, smaller still, is The Vision. Had I ordered the DVD edition, the cover would have been the same size but featured only the first four superheroes. Critics swiftly pointed out that the film’s relatively diverse cast had been reduced to four white guys. Or three white guys and one green one, depending on how angry everyone was.

Many comic book movies are far behind the comics that inspired them

Black Widow had already suffered the indignity of being removed from her motorbike, a toy version of which was sold with Captain America replacing her in the driving-seat. And you thought Sue Storm was the Invisible Woman. It isn’t unreasonable to ask why Marvel’s merchandising department are so behind the times compared with their film-makers. And likewise, many comic book movies are far behind the comics that inspired them.

When Wonder Woman appears in Batman v Superman: Dawn of Justice next year, it’ll be the first time she’s been featured on the big screen, though she has been almost continually in print for more than 70 years. Black Panther first appeared in a comic in 1966. He’ll finally get his own movie in 2018, after appearing in Captain America: Civil War next year.

Although Black Panther is widely regarded as the first black hero in comics, he was preceded by characters in Orrin Evans’ All-Negro Comics, a single issue produced in 1947. Evans – a black journalist – was decades ahead of other writers when he realised white kids weren’t the only ones who wanted to see themselves reflected in their comic book characters. “It’s New!” proclaimed the headline, above a picture of Ace Harlem, New York private eye, sharp suit beneath his rain coat, its collar turned up to meet the brim of his low-slung hat.

Perhaps the big screen has had trouble following the comic strips because viewers for the former aren’t always as tolerant as readers of the latter. Nick Fury was once so white that he was played on television by David Hasselhoff. But when Bryan Hitch and Mark Millar reinvented him in The Ultimates comic book series in 2002, he was black, bald and explaining to the rest of the Avengers crew that he would like to be played onscreen by Samuel L Jackson. His wish came true (unlike Captain America, who hoped Brad Pitt would take up his shield and Iron Man, who thought Johnny Depp was the guy to occupy Stark Tower on screen).

Yet when Michael B Jordan was announced as Johnny Storm in the most recent iteration of The Fantastic Four, plenty of internet commenters were driven wild at the prospect of seeing a previously white hero played by a black actor. Idris Elba suffered similar abuse when he was cast as Heimdall in Thor. It wasn’t realistic, people said, to have a Norse character played by a black guy (although a celestial bridge connecting Earth to the realm of Asgard was apparently no problem at all, in terms of realism).

Caped crusaders for change

Kamala Khan, otherwise known as Ms Marvel, is a Muslim teenage-girl superhero who patrols the streets of New Jersey. She brings a whole new dimension to the idea of a dual identity: she’s had to negotiate being a first generation Muslim-American (she is the daughter of Pakistani immigrants) long before she ever thought of putting on her superhero costume. There is no TV programme or film based around a Muslim character, let alone a female Muslim character, in the US – but this series of comics from Marvel is picking up the slack.

If comic books have been ahead of other mass-market media in their depiction of race, sexuality hasn’t gone unnoticed either. DC’s Midnighter, according to writer Steve Orlando, is “a confident, sex-positive take on the life of an active gay male.” An active gay male who can be found on Grindr, listing among his interests: “Violence (inventive)”. The world of comic books is, once again, light years ahead of the movie industry, where an unattached gay man is so often portrayed as tormented and so rarely shown as happy, even revelling in his single life.

Although the big comic book publishers like Marvel and DC have been denounced by some writers and artists for their money-grabbing obsession – in 2012, Alan Moore memorably dismissed the entire industry as “a bunch of gangsters” whose ethics have ‘not changed significantly in 70 years” — part of the appeal of comic books is that the barriers to entry are much lower than in other branches of the entertainment industry. Writers like Alan Moore and Neil Gaiman have always courted a diverse audience: Moore through his steadfast refusal to compromise or shut up, Gaiman through his breadth of work and, latterly, his extraordinary social media reach. It is surely no accident that the most potent visual symbol of anti-capitalist protestors over the last decade has been the Guy Fawkes mask, which replicates the one worn by V in Moore’s tale of civil disobedience, V for Vendetta. Comics have the capacity to be big business (Marvel’s film-making arm is owned by Disney, after all, and is responsible for three of the highest-grossing films ever made), but they can also create and embrace the counter-culture.

It is hard to imagine a story like Marjane Satrapi’s Persepolis could have been such a huge mainstream hit if it had been a prose text from a traditional publisher: much of its appeal stemmed from its lovely, deceptively simple graphics. Few people would have predicted that a French-language story of a little Iranian girl growing up in the aftermath of the Islamic Revolution would be an international bestseller. But that didn’t stop Persepolis from being named the fifth best book of the decade by Newsweek in 2010. Books published in French are all too rarely translated into English, and even more rarely adapted into award-winning films (not only did Persepolis share the Jury Prize at Cannes in 2007, it came close to winning the Academy Award for Best Animation, losing out to the – perhaps even more diverse – story of a Parisian rat who loves to cook, Ratatouille).

A recent issue opens with the stark image of a black boy lying on the ground shot dead by a white police officer

But even the most mainstream comic book characters are fighting important fights, and against more complicated nemeses than mere supervillains. Batman has his critics who say he’s not a real superhero, just a sociopath with a heightened sense of vengeance and a limitless credit card. But the caped crusader isn’t afraid to tackle one of America’s thorniest contemporary problems: institutional racism. A recent issue (Batman #44: A Simple Case) opens with the stark image of a black boy lying on the ground. He has been shot dead by a white police officer.

In the words of the issue’s writer, Scott Snyder, Batman discovers that methods which have previously been effective are no longer sufficient to solve the problems Gotham faces: “Finding a criminal, making an example of the criminal, throwing the criminal in jail… Instead, what he has to learn is that the problems that he’s facing in today’s city are much more humbling, are much more complicated.”

Comic books continue to blaze a trail across pop culture, reflecting the societies they emerge from. Their apparent binary morality – heroes and villains, good and evil – belies a far more nuanced social complexity. The truth at the heart of so many comics remains intact: sometimes, you need to wear a mask to show your true self to the world.

If you would like to comment on this story or anything else you have seen on BBC Culture, head over to our Facebook page or message us on Twitter.