I read it back in the early 90’s, it may have been in a collection of short stories. At the end the scientists tried to remember a joke but couldn’t and if they read a printed joke it wasn’t funny…
Jokester, by Isaac Asimov.
Noel Meyerhof is a "Grand Master", one of a small cadre of Earth's recognised geniuses, who has the insight to know what questions to ask Multivac. But a computer scientist is concerned that Meyerhof is acting erratically. As a known joke-teller, he has been discovered feeding jokes and riddles into Multivac.
By computer analysis, the characters in the story investigate the origin of humour, particularly why there seems to be no such thing as an original joke, except for puns. Every normal joke is something that was originally heard from someone else.
The computer eventually tells them that humour is actually a psychological study tool imposed on the human race by extraterrestrials studying mankind, similarly to how humans study mice. They needed to isolate the responses to their jokes from original ones, so they "programmed" us to react differently to puns.
The characters of the story conjecture that figuring this fact out makes humour useless as a tool, so the aliens will cease using it. And suddenly nothing is ever funny again.