If you'd asked me before I started this job whether I preferred teaching undergrads or grad students, I'd immediately respond with the later. I no longer agree with my former self.
These last 2 years, I've only had to teach upper level and graduate level classes at a small university with phenomenally motivated students, and I've uniformly liked my experience teaching undergraduates more than graduates. And that's not only because the prep for an undergrad lecture is easier than the prep for a grad lecture.
When my partner and I compare notes after our teaching days, he talks about his graduate students trying to apply the material in class to their own research problems, or raising points of view they have encountered in the literature of their subspecialty that are pertinent to the material in class. When I talk about teaching graduate students, I feel like I'm teaching to a wall of note takers.
I think this difference comes from the fact that in my field, due to the amount of specialized knowledge necessary, the first few years of a PhD really are just coursework to build up enough background to choose a potential thesis topic. And by they time you have a topic, you aren't taking classes anymore, but learning from the literature, your advisor, and a reading groups that you've formed with other students/faculty. In my partner's field, students often come into a PhD program with a general idea for a thesis in mind, and spend the first years honing it down to a clean, precise, specific question for which the data needs to be gathered and analyzed.
In contrast, the good undergraduates I encounter ask questions that relate the material covered in class to other classes taught in different departments where similar material has been covered as background, or to topics they may be interested in knowing for summer research. The good undergrads in his field are still surveying the subject, trying to figure out what can be done with the tools available.
These are two data points. Its tempting to draw a line through them saying that the less related to the student's current interests a class is, the less interesting it is for a lecturer to stand for an hour in front of the class. But then there is the entire world of labs, and rotations that I have no experience in. So, for other people: What factors of a class makes it fun to teach to?