Originally, this term was used to discuss a physical fall, specifically from a horse, and over time it was expanded to refer to metaphorical falls.
The phrase is first cited in Robert S. Surtees’ Ask Mamma, 1858: [He] “rode at an impracticable fence, and got a cropper for his pains.”
For the actual derivation we need to consider the nether quarters of a horse - the croup or crupper. In the 18th century, anyone who took a headlong fall from a horse was said to have fallen 'neck and crop'; for example, this extract from the English poet Edward Nairne's Poems, 1791:
A man on horseback, drunk with gin and flip,
Bawling out - Yoix - and cracking of his whip,
The startish beast took fright, and flop
The mad-brain'd rider tumbled, neck and crop!
'Neck and crop' and 'head over heels' probably both derive from the 16th century term 'neck and heels', which had the same meaning. 'Come a cropper' is just a colloquial way of describing a 'neck and crop' fall. By 1859, the phrase has come to refer to any failure rather than just the specific failure to stay on a horse.
The tall tale about the origins of “come a cropper” involves Thomas Henry Cropper, a man who developed a version of the platen printing press in the mid-1800s. The story goes that over time, all platen presses were referred to as “croppers,” and that someone could “come a cropper” by getting his or her fingers stuck in the workings of the press. While trapping body parts in a press is a very real danger of printing, especially with older presses, this charming story is patently false.