The riddle
Why Did the Cookie Go to the Doctor?
Two meanings of crummy
Crummy has two meanings in Merriam-Webster: very poor or inferior, and, in the learner's edition, feeling unwell or unhappy. A cookie leaves crumbs, and the word sounds like "crumb". The joke needs both. A person who feels crummy might see a doctor, and a cookie is made of crumbs. Merriam-Webster defines a crumb as a small fragment of food, and the soft inside of a loaf is also called its crumb. The link between the two words is easy to hear because the b in crumb is silent; crummy drops it from the spelling, though the dictionary also lists the spelling crumby.
Where the word cookie comes from
The Online Etymology Dictionary traces "cookie" to the Dutch word koekje, a little cake, and marks the word as American English. English took the word over from Dutch as the name for the treat. In British English the same thing is usually called a biscuit, a difference that Merriam-Webster notes.
A sound pun with a safe subject
This riddle asks little of the listener, and there is no medical detail to know. The cookie goes to the doctor for the same reason a person would, which is to feel better, and the pun does the rest. A crumbling cookie is a familiar sight, so the picture of a crummy one is easy to draw. The joke needs nothing from medicine beyond that.
A variation to try
Once the group knows this one, ask what other treats might need a doctor and why. Crumbs, flakes and cracks offer a stock of words to bend, and the best answers usually come from the room itself.