The American Cowboy was a figure in Human history and culture, particularly as part of the Ancient West. The cowboy was often reflected in films and literature as a "hero" character (ENT episode: "North Star"), and associated with a "shoot from the hip and hope for the best" mentality and cowboy diplomacy.
Beginning in the mid-22nd century, the Orions experienced a craze for 20th century Earth culture that included Westerns, after the UNSS Marco Polo sold them a number of Clint Eastwood movies and other cultural artifacts in reference stardate 0/7907.27 (c. 2150). They bought Western-style clothing, and imagined that 23rd century Earth was still inhabited by cowboys murdering Indians (FASA RPG module: The Orions: Book of Common Knowledge).
In 2268, James T. Kirk and a landing party took on the roles of "cowboys" due to Melkotian influence. The Melkot said Kirk's heritage should set the "pattern" for their death sentence (TOS episode: "Spectre of the Gun", TOS novelization: The Last Gunfight).