Why is "taking a biscuit" a bad thing in the UK?
N.B. Below is an image of the American dish, biscuits with gravy. Note that a biscuit in the US is similar to a scone, a type of cake.
Photo: Lizzie Munro/Tasting Table
This is what British speakers usually think of when using the term biscuit, a type of plain “cookie”
Image source: The Guardian
The following definitions of the idiom, take the biscuit, come from a wide selection of dictionaries on the Internet. It's worth mentioning that the British idiom take the biscuit, and its American English equivalent take the cake, refer to the treat being awarded. In other words, the biscuit (or cake) is the prize.
Note, not one dictionary mentions that the idiom is derived or is also the name of a masturbation game played by teenage British boys, as @SF's unsupported answer claims.
Collins: If someone has done something very stupid, rude, or selfish, you can say that they take the biscuit or that what they have done takes the biscuit, to emphasize your surprise at their behaviour.
REGIONAL NOTE:
in AM, use take the cakeLongman: (British English informal) to be the most surprising, annoying etc thing you have ever heard
Synonyms
take the cake (especially American English)Macmillan: (British informal) to be the most silly, stupid, or annoying thing in a series of things
Wiktionary: (idiomatic, Britain) To be particularly bad, objectionable, or egregious
Synonyms
(to be particularly egregious): take the cake (US)
(to be of no further use): have the biscuit (Canada)
In 2001, a James Briggs posted the following affirmation on The Phrase Finder
The origin of these sayings almost certainly lies in childhood contests where the winner's prize is a cake or biscuit, but modern use of the terms is almost exclusively ironic -- someone "takes the cake" when their conduct is shocking, surprising, or sets a new low in ethics.
The origin of “take the biscuit” is American
After a little digging, it appears that the British idiom is actually American in origin.
The earliest instance in print appears to be from The Wilmington Morning Star, N.Carolina (behind a paywall)
A Louisville reporter speaks of his town as «the pure city before which the Ohio river crouches and plays its music through the falls and hurries on.” This, it strikes us, rather takes the biscuit.
From Pueblo Chieftain, a Colorado newspaper, December 27, 1884
A man in West Newton takes the biscuit when it comes to queer ways of making a living. The individual in question now earns his bread and butter by supplying the good people of that city with hot water.
There are numerous instances recorded by Newspapers.com, from 1880 onwards, one is mentioned below:
But these days, it’s an exclamation to suggest that somebody has done something unprincipled that would win them a prize in a contest of unethicalness. An early example that shows how this sense developed was in the Fort Wayne Daily Gazette of Indiana in November 1880. There seemed to be a quarrel going on between the editor of the Gazette and a rival paper: “For pure cussedness, the new and exceedingly fresh young person [at] the Sentinel takes the biscuit.”
Taken from World Wide Words by Michael Quinion
Further reading
Clearing the air about taking the cake
Where did "that really takes the biscuit/cake" come from?
The conflicting origin of a “piece of cake”
Green's Dictionary of Slang has the etymology of take the biscuit
to beat all rivals, esp with the implication that the person, announcement, event, etc, is even more startling or appalling than might have been expected
as
the figurative sweetness or tastiness of the biscuit
and relates this to take the cake, take the baker's shop, take the beer, take the candied-peel, take the duff, take the flour, take the gingerbread, take the pastry and take the peach.
I'm not wholly convinced by this, but nothing I have found on Google is any improvement. Take the bun, Australian or American, is shown as having a slightly different meaning:-
to surpass, outdo, especially in excessive or extreme behaviour, to credit something with being the best or worst example
Apologies for quoting at such length, but Green really is the go-to man for information of this sort.
It seems to be ironical, having the sense that whatever has been said or done, even though it’s something bad, gets the prize for its extreme awfulness.
In answer to the OP's question How did the saying 'take the biscuit'" come to be?, here is an extract from the entry on the expression in The Penguin Dictionary of Historical Slang by Eric Partridge:
To deserve a prize for excellence; to be supremely remarkable. cf. take the BUN and take the CAKE. Recorded by 1890, but perhaps far older, for its origin seems to be late Medieval and early modern Latin. Wilfried J. W. Blunt, in Sebastiano (p. 88), records that the innkeeper's daughter at Bourgoin, a famous beauty, was present, in 1610, as a delegate at an International Innkeepers' Congress held at Rothenburg-am-Tauber. Against her name, the Secretary wrote, Ista capit biscottum, 'That one takes the biscuit'. ML possesses biscottus or biscottum, a biscuit.
And here is an extract from the entry on Take the cake:
... perhaps a jocular allusion to Gr. πυραμους, prize of victory, orig. cake of roasted wheat and honey awarded to person of greatest vigilance in night-watch ...
This leaves open the question as to when taking the biscuit flipped in British English from meaning especially good to particularly bad.
So, you grabbed both your initial definitions from Wikipedia. But if you simply click on the "take the cake" hyperlink there, the Wikipedia entry for that phrase reveals the "bad" or "egregious" definition of the phrase ALSO EXISTS IN THE U.S. In fact, as a Canadian, where we have some British holdovers, but mostly operate with an American lexicon, I am more familiar with a somewhat negative connotation of an extreme, as in "When it comes to being lazy, Johnny really takes the cake." In other words, even using your own source, your initial thesis of the difference between the U.S. and U.K. on this is incorrect.