The Western is a fascinating and perplexing genre of fiction. Though typically marketed towards older men, there are also children's books set in the genre and raunchy Harlequin paperbacks marketed towards women. Modern crime series Justified set in the deep south also explores many themes typical to Western novels. The HBO adaption of Westworld also explores many western themes albeit in the context of Science Fiction.
At it's core, you would think the Western is mere historical fiction and that without trappings of setting the themes of the Western are as baseless as air. This is an understandable assumption, but it is also wrong. The Western at it's core is about the frontier, it's not always a physical frontier and it's not always not one. It's about going out into the wilderness and maybe perhaps even coming back. But that's not as important as going out to begin with.
It's about being tested sometimes morally and sometimes physically, mostly both. It's about actions and consequences, crime and punishment, revenge in all it's forms, idealized and reviled. At the end of the day, the Western is about people being tested by their environment.
Whether that environment is made up of the trials of nature or the trials of the nature of man