Q. Is it proper for a frum teacher or Rav to make jokes in class or his drasha?
A. The Talmud (B'rachos 31a) mentions that: "It is prohibited for a person to fill his mouth with laughter in this world". Poiskim disagree whether this is only a propitious character quality (Rambam, Deos 2,7 - Ben Yehodoya, B'rachos 31a - Chida, Yair Ozen) or it is an actual Rabbinical prohibition (Ramban in Toras Ho'odom, Meiri ibid., Tur and Beis Yosef O.H. 560,6 et. al.) They also debate the reason. Some (ibid.) see it as form of mourning for the destruction of the Bais Hamikdosh, and therefore it did not apply when it stood. Others (Rabeinu Yonah, Ritvo ibid.) explain, that unrestrained frivolity can lead one to be drawn after worldly pleasures and cause the neglect of mitzvos and is therefore always relevant. Shulchan Aruch (O.H. 560:6) rules the above to be a prohibition and Mishna Berura (ibid. 20) quotes the Taz opinion that this applies even to a mitzva, although other Poiskim disagree (Orach Meishorim 30,9 - B'rurey Halochos 61)
However, a very fundamental distinction should be made, between a humorous story used to illustrate a point in Torah learning and what is referred to as "filling ones mouth with laughter", which connotes a total engagement in loud uncontrollable hilarity and unrestrained frivolity (Yosef Ometz and Birkas Yehoshua, B'rachos ibid. Tzidkas Hatzadik 260, see also Aruch Hashulchan 560). Also great care should be taken in not deriding or embarrassing anyone.
The Talmud (Shabbat 30b) relates that Rabbah would begin his teaching with a humorous and witty story and his students would laugh. So has been throughout the ages the way of many renowned lecturers and Magidim, who used comical parables as teaching tools. All in the spirit of the adage mentioned in Pirkei Avos (6,6) that the knowledge of Torah is acquired through joy.
Rabbi A. Bartfeld as revised by Horav Shlomo Miller shlit"a