The 'n' is known linguistically as a 'lubricative consonant', as it helps the speaker to articulate. 'A egg' would involve the speaker having to make a quick glottal stop between the first two sounds, in order to articulate the two vowels in such quick succession . The 'n' makes the need for a glottal stop redundant, and the sounds become more fluid. Try saying 'a egg' over and over again, as fast as you can; then 'an egg'. Which is easier, and which can you say faster? You should be able to feel the glottal stop in your throat after saying 'a egg' a few times.