If you're talking about the entirety of the history of the superhero genre—since, say, the start of the real development of it as a true lasting genre in cinema that began in 1978 with Superman: The Movie—then it's true that the 35-year history of the genre has seen ups and downs. Consider a little history first.
Superhero comics were, in the earliest days, actually read by kids and adults alike. There was a lot of violence and mature themes in them, and they addressed modern (for the time) issues like the Great Depression, urban crime (and the rise of organized crime in particular), world war, and so on. But they began to target younger readers more and more, adding kid sidekicks and focusing more on stories aimed at youth demographics. By the 1950s, a backlash arose that saw comic books as corrupting influences on kids.
So the Comics Code Authority was created, and strict standards were adopted to reduce violence, mature themes, rebellious concepts, and other content in comics. This ensured that they became so oriented toward younger readers that the mainstream perception of them was not as serious art or storytelling, but just "kid stuff." As the 1950s and early 1960s went on, the comics focused on outrageous tales of aliens, fantasy, monsters, and topics that further increased the perception of them as not for serious or adult readers.
Besides a 1951 big screen version of the popular Superman TV series (the film actually launched the television show and predated the Comics Code Authority, so it represented the earlier, more serious take on the character), there weren't any real attempts at big-screen superhero feature films until the 1966 movie Batman that was based on the popular campy TV show. It sort of lovingly mocked the comics and served to reinforce the popular public sentiment that comics were a joke.
This is all important background because of the widespread negative and nonserious perception of comics that existed in the public for several decades. When Superman was finally adapted to film in a modern way in 1978, it shocked people because it was mostly a serious take on the character, with a dramatic story, good acting, and amazing visual effects. It still had a sense of humor and contained camp elements, though, and studios didn't learn the right lessons because old perceptions die hard. Although people enjoyed those movies, they still also thought of comics as mostly for kids and nonserious material for the movies.
Therefore, when other early attempts at adapting superheroes to cinema were tried, the biases and inability to really understand and appreciate the source material—or to have a firm grasp of the best audiences to target—led to a lot of low-quality, bad movies. Batman was the standout, and his 1989 big-screen adaptation was a darker and more serious incarnation than anyone had really seen of a superhero in feature films. But after two such darker, almost sinister movies, the franchise decided to focus more on the child and family audiences with brighter production values and more jokes and camp in the stories. By the fourth film, it had collapsed completely into the old stereotype of being made purely for little kids, mostly for the purpose of selling merchandise like toys and Happy Meals. And all around, other low-rent attempts at superheroes continued, with few really solid entries in the genre in the early and mid-1990s.
But a funny thing had happened: The goofier, more campy and bad quality superhero films suffered a backlash from audiences. People who had previously perhaps been willing to laugh along with such camp didn't find it very appealing anymore. Their interest in the genre was there, and studios could sense the willingness of the public to turn out for superhero films. The problem was audiences now had a higher expectation—Superman's first two films and Batman's earlier attempts had shown people what was possible, and now audiences were more interested in movies that would offer a straightforward approach to the mythology of these superheroes. They wanted stories that were of the same level of good quality they'd desire in any other genre.
The late 1990s and early 2000s saw two key franchises arrive that kept the genre from falling apart—Blade and X-Men. Most studios and filmmakers had no clue how to properly approach the genre, and frankly they hadn't seen enough consistently high box office interest in superheroes (apart from Batman and Superman in a couple of movies each, which could be dismissed as simply arising due to initial interest driven by kids and the fact those two characters were so immensely recognizable) to care about putting more time and effort into making the movies better quality. But a few people did care and got it right, and those films were successful both financially and critically. And they paved the way for the really big change that was about to burst onto the scene and change everything.
Spider-Man was the only other character of stature similar to Batman and Superman, recognizable around the world and with fans even among adults who didn't read the comics. So a big-screen adaptation was inevitable, but it took time for visual effects to really make a good Spider-Man movie possible. And luckily, the rights were being argued over for several years and delayed any production in the 1990s—saving us from what apparently would've been a terribly campy adaptation that ignored a lot of the source material and that would've had much cheaper visual effects.
By the time Spidey finally made his way into theaters, CGI and other effects methods had evolved enough to do a good job. Meanwhile, the X-Men and Blade series had reminded studios that these were properties with built-in fan bases and merchandising opportunities that could be expanded to mainstream audiences if the films paid attention to the demand for higher quality filmmaking and storytelling.
And of course, Spider-Man was a massive blockbuster, and every studio suddenly realized how much money could be made from superheroes. Audiences likewise realized how good these stories and characters were, so they wanted more.
Within a few years, more and more attempts were being made to develop superhero franchises—some good, a few great, and quite a few just average or outright awful. But the process was a learning one for studios and audiences, to figure out what did and didn't work and what people really did and didn't want to see.
From about 2005 onward, the trend was toward higher quality and greater success overall: Batman Begins, Superman Returns, Iron Man films, The Incredible Hulk, Hellboy and Hellboy II, Captain America, Thor movies, The Dark Knight, Watchmen, Kick-Ass, The Dark Knight Rises, The Avengers, Wolverine, The Amazing Spider-Man, and several others show how far the genre has come.
Marvel's streak of great adaptations, the Nolan movies, the X-Men franchise, the Spider-Man films, and others stand as a testament to the fact the new millennium saw a complete change in the approach to comic books. Studios finally understand that the goal must be to find high-quality talent to make the films and that the source material itself is valuable and true art worth respecting in faithful adaptations.
So the only difficulties now in making a good comic book superhero film are to avoid the temptation to focus on cash-grabs and to rely too much on the popularity of the genre to make up for having a really good story and good filmmaking team involved in the projects. I think studios—especially Marvel, and now it seems WB (for DC Comics films) as well—are in most cases now trying to do things the right way and are mostly succeeding. The difficulties that used to exist were the public and studio perceptions of the material as childish and campy, but those problems have mostly been erased, and as a result the genre is now flourishing.
More questions on Movie Business: