Historical Development
Sometime prior to 1643, 'cowboy' formed in English by compounding. The original meaning was "boy [= man, usually young] who tends cows":
[58] John Birne late of Dongannon in the County of Tyrone deposeth, that he heard some of the native Irish that were somewhat more merciful than the rest, complain, that two young Cow-boys within the Parish of Tullah, had at several times murdered and drowned 36 women and children, Jurat. Jan. 12. 1643.
...or to consider that two [58] young Cow-boys should have it in their power to murder 36 Protestants.
From The Irish Rebellion, p 186, as reprinted in 1679 after the original publication in 1646, by Sir John Temple.
Merriam-Webster dates the compound to 1623, but does not provide attestation of its use at that early date. OED (Third Edition, as of June 2017), in an entry "not fully updated" and "first published 1893", gives a much later 1735 first attestation for this sense (1), from J. Swift. The previous version of the OED entry (from the 1989 Second Edition) dated the Swift attestation to 1725 (which accounts for the Etymology Online 1725 date). I find a use in Swift's "A Panegyrick on the D——n, in the Person of a Lady in the North. Written in the Year 1730" and published in Volume II, Poetical Writings of The Works of J.S., D.D., D.S.P.D. in Four Volumes in 1735:
But then, a Parson so genteel,
So nicely clad from Head to Heel;
So fine a Gown, a Band so clean,
As well become St. P—k's D—n;
Such reverential Awe express,
That Cow-boys know you by your Dress!
Early uses of the compound in Ireland in the seventeenth and eighteenth centuries likely employ a general sense of 'boy' extant at the time, but now only extant as the trailing element of surviving compounds,
A man, without connotation of age.
OED, sense 3d of boy, n.1 and int.
The next pertinent sense of 'cow-boy' was this US historical sense:
‘A contemptuous appellation applied to some of the tory partisans of Westchester Co., New York, during the Revolutionary war, who were exceedingly barbarous in the treatment of their opponents who favored the American cause’ (Bartlett Dict. Americanisms).
OED, sense 2 of cow-boy | cowboy, n., attested 1780–1857.
Sylva Clapin, in A New Dictionary of Americanisms (1902?), adds to this sense from Bartlett (via OED sense 2), that 'cow-boy' was also applied "in 1861 to semi-secessionnists in New England. At the time the term first came into usage in New York, the tories had obtained, in the eyes of their opponents, an unenviable reputation for their barbarous and ruffianly ways, and it is probable that the word was afterwards perpetuated as a name for cattle-herders, because descriptive of their real or alleged rough manners and customs" (emphasis mine).
Development of OED's sense 2 from the original sense 1 parallels the later (contemporary) development of use in the sense of
A person without qualifications who competes against established traders or operators, providing shoddy goods or services usually at low (or inflated) prices; one who is recklessly unscrupulous in business. Frequently attrib. slang.
OED, ibid., sense 3e, attested 1972–1985.
Figurative application of the compound by slang metonymy from the literal sense of 'a person or people who tend cows' to an aspect of behavior stereotypically attributed to those who tend cows, that is, unruliness in various forms, recurs in the later development from OED sense 3a,
In the western U.S.: A man employed to take care of grazing cattle on a ranch.
OED, ibid., sense 3a, attested 1849–1887.
to OED sense 3e (shown above).
Examples of Transitional Uses
Transitional uses of the compound were relatively easy to uncover, although the historical record readily available to me is unfortunately spotty. Setting aside the now legendary reputed unruliness of trail-driving cowboys, promulgated in the popular imagination by way of romantic Western novels, wherein cowboys are represented as having driven cattle herds through towns, whooping and hollering and shooting up the place, this short "globule" appears in The Saint Paul Globe (Minnesota) of 13 Jul 1884 (paywalled):
The way one of the Fort Snelling mule coaches switched around on the corner of Fourth and Wabashaw streets, to the imminent danger of running down pedestrians, yesterday noon, with its cow-boy driver, was an example of reckless driving which don't want to be repeated.
The use corresponds, although from an earlier period, to sense 3b as given by OED and attested from 1942–1984 therein:
A boisterous or wild young man .... Also spec. a reckless or inconsiderate driver of a motor vehicle, esp. a lorry. slang (orig. U.S.).
The Saint Paul Globe "globule" has a semi-literal correspondence with 'cowboy driver' in OED sense 3b, as does this from the motor age:
"He's a cowboy. He was crippled by falling under his horse, so I had him instructed to run the car. He can drive, don't you think?"
"Drive? Good Gracious! He scared us to death, except Castleton. Nothing could scare that cold-blooded little Englishman. I am dizzy yet. Do you know, Majesty, I was delighted when I saw the car. Then your cowboy driver met us at the platform. What a queer-looking individual! He had a big pistol strapped to those leather trousers. That made me nervous. When he piled us all in with our grips, he put me in the seat beside him, whether I liked it or not. I was fool enough to tell him I loved to travel fast. What do you think he said? Well, he eyed me in a rather cool and speculative way and said, with a smile, 'Miss, I reckon anything you love an' want bad will be coming to you out here!'
The Daily Times (Salisbury, Maryland), 28 Dec 1923, p 5 (paywalled). From a serialized version of The Light of Western Stars, by Zane Grey.
Further uses of 'cowboy' and 'cowboy driver', in the figurative sense given as OED 3b, and from years before OED's first, 1942, attestation of that sense, are in evidence. For example, this from The Central News (Perkasie, Pennsylvania), 15 Apr 1937, p 3 (paywalled):
The speediest "cow-boy" driver to be "blown down" by a State Highway Patrol Officer during the past week was Albert Swith, of Passaic, N. J., who was clocked at 78 miles an hour on the Bethlehem Pike....
A superabundance of search results for 'cowboy' alone, and a derth of results for 'cowboy' collocated with likely terms ('merchant', 'builder', 'contractor', etc.) made finding transitional figurative uses for sense 3e a test of stamina. Some telling examples did, finally, emerge. For example, this compelling use from The Plain Speaker (Hazleton, Pennsylvania), 19 Feb 1901, p 4 (paywalled):
Another transitional figurative use, which participates in the facet of meaning common to all the figurative uses discussed in the foregoing, the facet of 'unruliness', is this from The Buffalo Commercial (Buffalo, New York), 09 Apr 1851, p 2 (paywalled):
A Whig is not a Whig, unless he supports Whig measures as shadowed forth in the policy of the Whig administration. The opposition is now composed of two distinct sections — the open, manly, organised opposition of the Democrats, and the sneaking, cow-boy opposition of the spoilsmen, who sail under the banner of free soilism — and who are ever ready to sell themselves to the highest bidders — the higher law men, who have no higher aims than selfishness and a long for place and power.
Examples of figurative political uses continue to appear at least throughout the mid-1800s, including this definitive example from Raftsman's Journal (Clearfield, Pennsylvania), 27 Apr 1859, p 2 (paywalled):
A New Name for Them. — In Vermont, they have what are called "Cow Boy" Democrats — which are defined to be "professed Democrats, who go where plunder leads the way, and who care nothing for principles, if they can grab an office."
Cowboy Summary
The common thread running through all the figurative uses of 'cowboy' discussed in the foregoing is that of unruliness bordering on unlawfulness, and it is that aspect of 'cowboy' behavior that gives rise to OED sense 3e, "A person without qualifications who competes against established traders or operators, providing shoddy goods or services usually at low (or inflated) prices; one who is recklessly unscrupulous in business". While OED attests the sense from 1972, it is in use much earlier, as is attested by its use in advertising in The Plain Speaker from 1901, and such uses would have been readily understood even without more general currency on the basis of their participation in the sense of 'unruliness bordering on unlawfulness'.