Teacher: You should have been here at 9 o'clock
Student: Why, what happened?
This pun relies on the different uses of the modal auxiliary "should". Two of these uses are:
should for obligation
If a policeman says to you "You should be wearing your seat belt", it means that the law requires you to wear your seat belt in the car.
should for advice
If your friend says to you "You should see the new James Bond film", it means that he thinks it would be a good idea and you would like it.
The student thought the teacher was offering advice.