I was always curious if this common portrayal had any historical relevance or if it was just to add something cool while making a movie.
So I can speak to the primary and secondary resources from the mid-to-late 19th century to offer one perspective. Of course, people could have spun their guns as something of a hobby, but it just wasn't written about at the time. The origin for this myth is rooted in Buffalo Bill's Wild West troupe, and was further romanticized in the 20th century when motion pictures brought American western drama to the masses. Primary sources from the period in question (the classic "old west" era is usually set or defined anywhere between 1866 - 1899, with no mutually agreed upon stop/start point) don't write about this practice. Newspaper and diary entries from this period don't make any mention of shootists (as hired guns were often referred to) doing this, and the dramatic literary fiction from the period didn't make mention of the practice (i.e., Dime Novels written in the 1860s, 70s, and 80s). The first real evidence we have of people spinning their guns in the manner OP referred to didn't come to the public's attention until Buffalo Bill's Wild West (Bill chastised people who called it a "SHOW").
Buffalo Bill's Wild West was a travelling circus of sorts that did dramatic reenactments (often with genuine Native Americans participating), trick shot demonstrations, and roping/riding displays. In the 1870s and 80s, Buffalo Bill's Wild West was MASSIVE. If they came through your town, businesses and schools shut down, and pretty much anyone who could go went. The act was an even bigger hit overseas (the Europeans ate it up), and people who had only read about "The West" in Dime Novels got to see what they'd only fantasized about IRL. In the pre-radio/TV/movie days, it was like the Superbowl, World Cup, and a Marvel movie all rolled into one.
The Dime Novels telling these Wild West stories had already been selling like mad, relating these fanciful cowboy and indian stories to folks, so having Buffalo Bill and his Wild West roll through town was like seeing your favorite book adapted for the big screen...EXCEPT in this case, it was never a let-down. People who saw this as kids, especially, never forgot it. So the people who performed in these shows, it was their full-time job in most cases, so in between acts, or when they were on the road, they had nothing but time to practice their craft, and build on it. Thus, skilled marksmen (and women!) who had nothing but time on their hands developed a number of roping, riding, and gun-handling tricks to keep upping the "wow" factor for their acts. People who weren't entertainers didn't have this much time to dedicate to learning how to spin a revolver (though it stands to reason that others had toyed with the practice, just in obscurity), but full-time trick-shot artists had the luxury to experiment with many of the tricks we are familiar with today.
And while the classic, non-show-biz "shootists" like Tom Horn, et al did actively practice with their pistols to become frighteningly proficient with them, they didn't have the time (or motivation) to spend learning how to twirl and spin their shooters like what we know from the movies. It just wouldn't have done them any good, because a real shootist wouldn't have bothered with something that might have slowed them down, etc.
Or maybe they did, and no one wrote about it (or saw them do it). Or maybe people did see them do it, and thought so little of it that they didn't write about it. The point is, we don't know that non-show-biz folks did this, but we DO know that people in Buffalo Bill's Wild West DID do it, and that the people who got into filmmaking in the 20th century were impressed enough with it that it started making its way into motion pictures. This was likely the result of extras and stunt men who had grown up watching performers in Buffalo Bill's Wild West (or similar shows) do this, and probably played around with the practice as adults. These guys would have been on-set, and fooling around between takes, and it then made its way on-screen.
[Sources, Richard Slotkin, 'Gunfighter Nation'; Michael Denning, 'Mechanic Accents'; Prentiss Ingraham, Any of his 500+ Dime Novels]