“If a farmer fills his barn with grain, he gets mice. If he leaves it empty, he gets actors.”
-Sir Walter Scott
“The stable wears out a horse more than the road.”
Aside from amusing us, the quotes above actually tell us something about the difference between a barn and a stable. The essential difference revealed is that stables are for horses (and other domestic animals) and barns are for actors.
Ok, not really for actors. But clearly the idea is that barns are considered multi-purpose structures and stables are for horses. You might keep a horse in a barn but you could also keep supplies, farm implements, tractors, and actors in them.
You've never seen a Western in which John Wayne, in some small town, said, "Jimmy, take the horses down to the barn." No. He tells Jimmy to take them to the livery (short for livery yard or livery stable in the UK) or to the stable (short for boarding stable in N. America, Australia). On the ranch he might tell Jimmy to take them to the barn.
Stable can also be used as a verb. To stable a horse is to put them in the stable.
In general, farms produce crops and ranches produce animals, although there are horse farms. The USDA states a farm is "any place from which $1,000 or more of agricultural products were produced and sold, or normally would have been sold, during the year." The USDA's definition of a horse farm is one where the facilities are used for producing horses (breeding) rather than a facility used to board horses and ride them, which the government considers as being for recreation.
All horse people know that the bottom line is that you can call it a barn or a stable and we'll know what you mean. Just don't forget where it is.