For the sake of argument, let's assume you're in a class where you already know the material, and it's clear that this lecture is not going to reveal anything new.
Sleeping or visibly goofing off would be rude. Fortunately, you're in school, so presumably you have work you can be doing - whether that's reading for another class, reading ahead in your current textbook, or composing that essay in your head.
Free time when you're not stuck at a desk is more valuable than free time right now. Therefore, you should be doing work now to get better free time later.