^hmm... I think Asimov answered that question partially at least in the short story called "The Joker". Dont know if that was what the Foundation story was referring to, but Asimov uses the same themes and ideas across many of his books (eg: Univac), Spoiler alert: According to the Joker, the jokes were of extraterrestrial origin meant as a psychological study of mankind.