"The bees knees, the cats pyjamas, the caterpillars spats"! Where and how did this saying originate?

The bee's knees is an English slang phrase.

The Oxford English Dictionary records the expression "bee's knee" from 1797 as meaning something small or insignificant.

The phrase "the bee's knees", meaning "the height of excellence", became popular in the U.S. in the 1920s, along with "the cat's whiskers" (possibly from the use of these in radio crystal sets), "the cat's pajamas" (pajamas were still new enough to be daring), and similar phrases that didn't endure: "the eel's ankle", "the elephant's instep", "the snake's hip" and "the capybara's spats".

The phrase's actual origin has not been determined, but several theories include "b's and e's" (short for "be-alls and end-alls") and a corruption of "business" ("It's the beezness.")
We have a book of idioms that we got from a school book fair that explains the origins of several.
Two of our favs here in the UK are The Mutts Nuts or
The Dogs Boll ocks !
Has several definitions and origins as well as books to purchase for further details.
The first two became popular during the Roaring Twenties (1920's) in the US. The "bee's knees," meant "the height of excellence," as well as the "cat's whiskers", and the "cat's pajamas".

One story about the origin of the "bee's knees" includes "b's and e's," short for "be-alls and end-alls" meaning the best.

I couldn't find anything on the caterpillars spats but I would guess it's from the same era also meaning "great", "cool",
Yay for the twenties. "Cool" also came from back then though we use it a lot more now.

Think of all the weird stuff we've said, or heard from past generations. I'm sure most of us would sigh in shame thinking of the 80s. "Radical", "gnarly dude", "eat my shorts", "like, whatever" etc. Yay pop culture. *sigh*

It's funny what we come up with and even more interesting, what sticks around! I like "the cat's meow" as an oldie but a goodie. Also, "groovy" from the sixties.
These are popular sayings from the "Roaring Twenties," age of the Speak Easies (places where people met in the days of Prohibition) I believe the sayings originated in places like that, but I could be wrong. I am right about the era. The bees knees and the cat's meow, etc,. refer to a person or thing that we might say is really "cool." I like their sayings better.
Now if you had asked, 'Trouble and Strife, 'Up the Apples', 'the Whistle' etc. ,- and believe me many, many more similar, then the answer would be Cockney Rhyming slang from good old London Town. I believe it originated as a sort of code language used by East End Market Traders at the turn of the century. To be a Cockney you had to be born within the sound of the Bow Church bells.
(Trouble = wife), (Apples and pears = Stairs - going to bed) and (Whistle and 'flute' = Suit)