But in stories where a hero is necessary, is it necessary for those heroes to be good.
I would argue that the answer is no. That paragons of goodness, the paladin type, is utterly dull (unless you're making fun of it as they do in The Gamers, or use it as a source of conflict). Hear me out on this one.
Certainly, in some instances, it absolutely works. Superman and Captain America were both written as utterly upstanding people. They are the paladin-type of hero; do no evil no matter what. For them, it absolutely works, and can make for a brilliant foil for the shadier characters trying to do the right thing. Problems often arise when people try and re-imagine these characters as darker and grittier than they are (looking at you, DC movies). Marvel has managed to find the balance with Captain America, making him principled to a fault, and I mean a fault, to the point where it ruins friendships.
For the record, I had always found Superman boring, and the only Captain America I know is movie Cap (and I enjoy that character a lot), so that's what I'm going from.
Anyway, that was a side-track.
Of course, it's hard to argue that heroes must be such paragons of goodness, given the popularity of the anti-hero archetype. There's a reason why Wolverine is one of the enduring favourites of the X-Men franchise, and it's not because he's Canadian. It' because he's rough, and willing to do play pretty dirty tricks to get the job done. That's why I won't stop ranting about Joel from The Last of Us.
I tend to gravitate towards the anti-hero type; the person trying to do good things but tends to resort to awful things to get them done (like Joel torturing men in order to rescue Ellie). The dichotomy of good and evil existing in a single character at the same time is fascinating to me. The struggle to do good where good is in short supply is far more interesting to me than other kinds of stories.
Perhaps it's because it feels more real to me.
There isn't a single person alive who is goodness personified. We all have our flaws. Our weaknesses are not external to ourselves (*cough**cough* Kryptonite). Sacrifice and loss are painful. Decisions are difficult. It gets dull to watch a hero without flaws and weaknesses, who isn't afraid of loss and doesn't agonise over the difficult decisions that have to be made when faced with overwhelming odds.
Heroes, I think, are all the more heroic if being a hero doesn't come easily.
Now speaking of heroes, have you seen the Avengers: Infinity trailer? 'Cause damn!