Easy - because "apple" begins with a vowel and "pear" with a consonant.
But suppose you push for further explanation - one thing leads to another, and you have a really interesting discussion.
Here's a script, starring you and an ideally thoughtful and well-informed class.
You: Why do you think we write "an apple" but "a pear"?
Them: Is it because "apple" begins with a vowel and "pear" with a consonant?
You: Yes, but what about "unit"? That starts with a vowel too, but we write "a". Why?
Them: Because what counts is the next sound, not the next letter. It's true that the first letter of "unit" is a vowel, but its first sound is actually the same as in "youth" - a "y" sound.
You: Can you think of any other words where sounds and letters are out of step?
Them: Yes, lots of other words starting with "u" - "universe", "ufo", "utility". But most words with "u" are like "uncle" and "up". Then there's "hour" and "honest", which go the other way - the first letter is a consonant, but we don't pronounce it so the first sound is actually a vowel.
You: Good. So when we choose between "a" and "an" we're actually paying attention to the next sound, not the next letter. So what's the easiest way to decide whether to write "a" or "an"?
Them: Spell it as you say it.
You: That's right. The pronunciation comes first, and the spelling follows.
Can you think of any other words that have different pronunciations before consonants and vowels?
Them: How about "the"? If it comes before a vowel it sounds like "thee", but it has the same vowel sound as "a" before a consonant.
You: Good thinking there! And good listening. The vowel of "a" is what's called schwa, and you can write it like this: J. Do any other words end in schwa?
Them: Yes, lots - "writer", "sofa", ...
You: So what happens to them before a vowel? Try putting them before "is".
Them: Well, we pronounce the "r" in "writer" - and we add an "r" to "sofa".
That's weird, isn't it? So it looks as though we'll do anything to avoid schwa before a vowel.
You: That's right. We really hate schwa before a vowel, so we put something else in to separate them. Most words just add the "r" that's in the spelling, some add one that's not in the spelling, and a tiny handful have special rules, like "a" and "the". So now you understand a bit better why "a" changes to "an". It's a sign of the way you need to keep your ears as well as your wits about you when dealing with language.
Richard Hudson is professor of linguistics at University College, London Geoff Barton is headteacher of King Edward VI School, Bury St Edmunds, Suffolk