I've been talking about the various shades of heroes, focusing mostly on those who might not seem like the traditional hero -- the ones who are darker or flawed. These days, though, it seems like it's easier to get audiences interested in these darker heroes than in the traditional good guy. I was recently on a convention panel about bad boys vs. good guys, and someone said that the good guys are boring, which is why people like the darker heroes more. I said that if your good guy is boring, then you're doing it wrong. But how do you write a good guy people will like?
First, you have to like the character. If you think your white-hat hero is a sanctimonious, boring goody-goody, you can't expect your readers to like him. If you're not doing that on purpose because you think it's a twist to have the white-hat guy be a jerk and the darker guy be the real good guy, then think again about why you want this character in your story. If this isn't the sort of character you can write well, then don't try to make it work. Go ahead and write the character who appeals to you.
A nice guy doesn't have to be perfect. Another comment made at that panel was that it's hard to relate to a pure and perfect hero. My response was that the hero doesn't have to be pure and perfect to be good. Even the best people with the noblest intentions can make mistakes or fail. Attempting to do something nearly impossible and having a bad outcome or being misled by someone with evil intentions doesn't even create a shade of gray. Good people can have bad moods, be discouraged or snap at people. Good people can have flaws and blind spots. A generally positive trait can become a flaw in some circumstances. Being too trusting or too self-sacrificing can be a flaw. Good people can have fears and phobias and weaknesses that they try to resist.
It also helps if the hero doesn't see himself as perfect and if other characters recognize his flaws. I think this is the main thing that's turned audiences off of a lot of the traditional heroes. Writers forget to have the hero recognize his own flaws or be at all self-critical. The guy who's noble and righteous and who sees himself that way can come across as a bit of a jerk or holier than thou. In real life, people are often harder on themselves than anyone else can be, and they're more conscious of their own flaws than other people are. You don't want to overdo this, though, where the hero is constantly beating himself up for invisible flaws, to the point where it looks like the hero's biggest flaw is that he doesn't realize how awesome he is. He just needs to be realistic about himself and aware that he isn't perfect while he tries to improve. On the other hand, it can really help gain audience support if the hero is a bit of an underdog, if the other characters underestimate him, dwell on his flaws or misinterpret his motives. That generally works a lot better than if the other characters are full of non-stop praise or if they don't seem to see flaws that are obvious to the audience.
It's okay for the white-hat good guy to have a sense of humor. That seems to be another misconception about this kind of character. I keep seeing the Luke Skywalker vs. Han Solo comparison when the good boys vs. bad boys issue comes up, with the idea that you get the bad boy Han Solo with all the funny quips and boringly earnest Luke Skywalker. But if you really look at those movies, Luke is very funny, as well. I got sucked into one of the marathons on cable a while ago, and I was astonished by just how many of the funny lines or funny reactions came from Luke. He wasn't at all humorless. He was actually quite snarky, he had Han's number from the start, knowing just how to manipulate him, and he gave as good as he got from Han. If you let your good guy have a sense of humor and give him some of the good lines instead of reserving all the fun stuff for the bad boy, you'll go a long way toward making him someone we want to cheer for.
When you're writing a more traditional good guy hero, take advantage of the possibilities inherent in the character. One of these is contrast. You can get a lot of drama and humor out of a contrast between character and situation. A dark bad boy hero in a dark, dangerous world isn't all that interesting. Put an earnest nice guy in that dark, dangerous world, and you've got something you can play with. There's also a lot more potential drama and angst about putting someone with a strong moral compass into an impossible situation. The darker hero may be more of a pragmatist and able to make the rational decision, even if it's a lesser of two evils. The guy who really believes in doing no harm and who has lines he can't make himself cross is going to have a lot more trouble when he's between a rock and a hard place that involves a moral dilemma in a choice between two evils or two mutually exclusive goods. But trying to make a moral choice doesn't mean a good guy has to be stupid or that you have to frame the situation that way -- like the common trope where it's presented that the good guy killing the bad guy who is in the process of killing or hurting multiple people is somehow an evil act, so in order to remain truly good, the good guy can't really do anything. And sure, lots of innocent people died, but the good guy's hands remain clean, and that's good! You have to let your good guy be smart. He can feel bad about being forced to kill someone, even as he recognizes it as the right thing to do, without him turning to the dark side because he killed the villain. Screwy morality is one of the big things hampering the good guys in fiction.
I've been using the masculine pronoun here for simplicity, although it applies to all heroes. However, it's a lot trickier with a female protagonist because it seems like audiences are harder on them, and a lot of the criticism comes from women. A white-hat heroine who's at all competent is likely to be labeled a Mary Sue and dismissed. That's why it's important to let a character have flaws that are recognized. Sadly, it seems like a female character who's at all confident in herself will be labeled a bitch. On the other hand, the dark bad girl generally has to act like a man in drag and will be criticized if she acts at all feminine. I don't really know what the solution is, other than to try to write decent female characters while ignoring the inevitable backlash criticism and support as a reader or audience member the good female characters who are out there.