Take a look at the screenshot above, from an old Hollywood Western. It’s not likely you’ve ever seen this exact film, but can you say which of these men are the goodies and which are the baddies?
The answer is that the men wearing the white hats are the heroes and the men wearing black hats are the adversaries. As Marjery Hourihan explains in her book Deconstructing The Hero, this overt distinction in hat colour was necessary precisely because the behaviours of the ‘heroes’ were not otherwise different from the behaviours of the ‘outlaws’. In other words, when determining who the goodies and baddies are, in life as in literature, relativism is everything.
The circumstances which have made the criminals what they are, or the values which label and reward the hero, are not examined….Criminals in adventure sories which condemn them as wild things are often guilty of no worse deeds, by conventional standards, than the heroes but they are seen from the hero’s point of view and the inferior terms of the basic dualities are attributed to them. They are depicted as uncivilized, irrational, governed by uncontrollable drives and passions, animal-like.
– Deconstructing The Hero by Marjery Hourihan
The psychology of superheroes (and villains: What we learn about personality when we analyze good guys, bad guys — and ourselves from The Boston Globe (notice that superheroes and villains are different sides of the same coin. There’s not all that much difference between them, if any.)
For a good example of the black hat, white hat trope, in ‘the Western film for people who don’t like Westerns’ (according to Australian film critic David Stratton), watch Shane (1953).
See also this infographic of ‘Alignment Abuse’ which outlines the ways in which characters are classically (stereotypically?) defined on the good-evil continuum in popular stories.