Here's an article on how to use humor in the classroom, especially in those classes that students all have to take but don't necessarily see as relevant to their major. As the authors note:
"Humor is a valuable teaching tool for establishing a classroom climate conducive to learning...Appropriate and timely humor in the college classroom can foster mutual openness and respect and contribute to overall teaching effectiveness."
They go on to say: "Humor is a catalyst for classroom "magic," when all the educational elements converge and teacher and students are both positive and excited about learning. Instructors can foster classroom "magic" through improved communication with students by possessing a playful attitude and a willingness to use appropriate humor."
Thus, humor in the classroom helps to reduce the anxiety students feel and makes for a positive learning environment. In one of my classes, there were a number of students who came in tardy which is actually very unusual in my classroom. It turned out that there was an event on campus that had filled up the parking lots. I didn't know this and was lecturing and every 2-3 minutes another student would come into class. The first one I ignored, the second one I stopped and looked at, the third one I made a comment. By the fourth person I paused and started laughing. Obviously something was going on out of the ordinary. I then accused the students of all standing outside the classroom text messaging each other and deliberately sending in one late student at a time. The class thought it was hilarious. It made the point that I was paying attention and yet didn't place any blame. I find humor a good way to manage the classroom.