From Old French 'messagier' — the intrusive '-n-' arose by the same process that produced 'passenger' and 'harbinger.'
A person who carries a message or messages; a person employed to carry communications between parties.
From Old French messagier (a messenger, envoy, ambassador), from message (message, errand), from Medieval Latin missāticum (something sent), from Latin missus (sent), past participle of mittere (to send). The excrescent -n- in English messenger (rather than messager) developed in Middle English by the same process that produced passenger from passager, harbinger from herberger, and scavenger from scavager — an intrusive nasal consonant inserted before a final unstressed syllable, possibly by analogy with agent nouns ending in -nger or -enger. A messenger is thus etymologically a sent person — not merely one
The '-n-' in 'messenger' is an intruder — the original form was 'messager,' directly from French 'messagier.' English inserted a parasitic '-n-' before the '-g-' during the Middle English period, the same process that turned 'passager' into 'passenger,' 'porringer' from 'potager,' and 'harbinger' from 'herberger.' Linguists call this an 'excrescent nasal,' and it remains one of English's more peculiar phonological habits.