Yes, it’s a pun. 用がない or 用なし (ようなし) and 洋梨 (ようなし) or pear. And puns are funny.
Before kids enter the staff room, they have to stand at the door and say, 「X年生のYです。Z先生に用があってきました。」(Or at least that’s what it sounds like to me. Correct me if I’m wrong.) In English, "I’m Y from the X Grade. I need to see Z-sensei."
I’ve translated it as "need to see Z-sensei," but it’s actually the word 用 (よう), which means reason – so it’s almost like "I have a certain need/reason to see Z-sensei." It’s also used in the very similar 用事 but not in 予定. Watch your long vowels.
(In the original puzzle I translated it as "and I’m here to see Z-sensei," which I think is even more natural in the English.)
Aleisha and Robin both provided correct answers, and the winner by coin flip is Aleisha.