Actually, it's a hold over from supplying teachers with their room and board out on the frontier: Giving teachers apples Apples were like potatoes are today for many, many centuries. Most recipe books going back to the middle ages have some sort of apple dish either as the main dish or as the side - just like no cookbook worth it's weight in salt wouldn't have some sort of baked potato or french fry recipe in it today.
Apples were also associated with the tree of knowledge in the Bible - although the Bible only ever says "fruit" not apple. Very long story as to why the apple is associated but, when it comes to teachers, not only are you still paying their "board" but you are showing that you associate them with knowledge.
This Smithsonian article, citing a PBS programme 'Frontier House, Frontier life' explains that frontier families were often responsible for the housing and sustenance of teachers in frontier classrooms and so students would have brought food for their teachers during lessons.
I could find no consensus on why this tradition continued with apples in particular but theories include -
Impact of marketing of newly developed eating-apple (as opposed to cider-apple) variates, made the fruit more desirable.
A symbolic association with the Biblical tree of knowledge, which was apt for the classroom.
Apples used to make cider in areas where the water was not potable.