Where does this hyphen come from? You already know the answer, of course.
There's a very useful punctuation rule which uses hyphens to show syntactic structure. It hasn't got a name, so let's call it the "hyphenated-modifier rule". (Note the hyphen!) This is the rule that puts the hyphen into "ancient-history teacher", and it shows that "ancient" modifies "history", not "teacher": "(ancient-history) teacher", rather than "ancient (history teacher)".
The hyphenated-modifier rule inserts an extra hyphen to remove ambiguity.
The hyphen between words A and B shows that A modifies B and not word C which B modifies; so it signals the structure on the left, in contrast with the one on the right: In some cases the hyphen avoids a dangerous misunderstanding. For example, it really matters whether you are an ancient-history teacher or an ancient history teacher, and there's a big difference between our first class outing and our first-class outing. In other cases only one meaning makes sense; but in every case, the hyphen is kind to the reader because it resolves a temporary uncertainty about the structure.
This rule is well worth teaching, and a good class activity would be to collect examples and discuss them. But the rule is also interesting in its own right because hyphens are basically part of word-level grammar, as in "ice-cream", "ex-wife" and "co-ordination". These hyphens are in the dictionary, and we think of them as a matter of spelling. But the hyphen in "ancient-history teacher" is different. This is pure syntax, ie, sentence-level grammar, because "ancient" and "history" are separate words, and the hyphen indicates their close syntactic bond.
This makes a good topic for classroom work because it's such a vivid demonstration of the importance of punctuation, the effect of a small horizontal mark on the page to help a reader understand the writer's meaning. With practice, students will quickly spot different meanings in juxtaposed phrases like second-hand car salesman and second-hand-car salesman. Such is the power of hyphens.
Richard Hudson is professor of linguistics at University College, London Geoff Barton is headteacher of King Edward VI School, Bury St Edmunds, Suffolk