1725, "boy who tends to cows and drives them to and from pasture," from cow (n.) + boy.
American-English sense of "man employed to have care of grazing cattle on the Great Plains for a stockman or ranch, doing his work on horseback" is by 1849. Earlier it was an insulting name for a band of marauding loyalists in the neighborhood of New York during the Revolution (1775). In figurative use by 1942 for "brash and reckless young man" (as an adjective meaning "reckless," from 1920s).
The oldest word for "one whose occupation is the care of cattle" is cowherd (late Old English).Cowhand is first attested 1852 in American English (see hand (n.)). Cowpoke (said to be 1881, not in popular use until 1940s) was said to be originally restricted to those who prodded cattle onto railroad cars with long poles. Cowboys and Indians as a children's game (imitating movie serials, etc.) is by 1941.