I have to admit that I don't mind watching a movie or reading a book where the hero doesn't have a happy ending. Okay, it has to be done well because I have seen some movies where I just feel like the director just wanted to trash the main character, but then I have also seen some movies where the happy endings felt to have come around through too much of a coincidence and everything is "too" happy.
So, how can a sad ending be worthwhile to the reader or viewer? That all depends on how the story and characters develop. I have to believe the main character has tried their hardest to overcome their problem or defeat their antagonist and still nothing has worked. These storylines are often present in apocalypse stories where the viewer knows that no matter what the character does, they're still not going to be able to stop the big tragedy that's coming, but the character still tries to change the outcome. If the character doesn't try and just gives up (yes, I've seen movies like that) then the ending sorts of fizzes out.
Okay, here is my personal choice: I would rather have a character try and fail than to have a character not try and just be given their happy ending. A sad ending with a hero that has put everything into trying to achieve his goals is better than a coincidental happy ending where everyone gets what they want even though they have not earned those things.
What do you think? Would you prefer the happy ending or the sad ending?