The riddle
What Do You Call a Bear with No Teeth?
A bear with only gums
A bear with no teeth would have nothing but gums, so "gummy" is a fair name for it. "Gummy bear" is also a chewy candy, and the riddle works by letting both pictures sit together: a toothless animal and a sweet shaped like one.
The question starts out sounding like a nature question, which is why the answer gets a laugh. Nobody expects a candy.
Where gummy bears began
The candy goes back to Hans Riegel, who started a company in Bonn, Germany, in 1920. He named it Haribo from the first letters of his name and his town: HAns RIegel BOnn. According to Smithsonian Magazine, he introduced a bear-shaped gummy in 1922 and called it the Dancing Bear, after the trained bears that performed in shows of the time.
The "what do you call" form
Riddles that begin "what do you call" ask for a name, so the answer is usually a pair of words that the listener has heard many times and never connected to the question. The pun in when is a door not a door works the same way: the answer is an everyday phrase that a different sentence has been hiding.