The Westerner (1940)
I am not usually a fan of Gary Cooper, but he shows a wry self-deprecating humor in this western about the classic struggle between homesteaders and cattlemen. Judge Roy Bean, played by Walter Brennan, hates homesteaders and loves the actress Lily Langtry. Cooper, a drifter enamored of a local girl, uses Bean’s adoration of the actress to save his own hide from the hanging judge and help out his homesteading friends.
For more on the film and its impact on Cooper’s career, check out this TCM article.