That's why the 'n' is inserted (and creates 'an')

Actually® the n was there first and was lost through elision before words starting with a consonant sound (it's even harder to say "an book" than it is to say "a apple"; witness the fact that "a" is the onliest indefinite article in many dialects). The indefinite article was derived from the word for the number 1.