Tchrist's answer citing the Oxford English Dictionary pretty much says it all (so please vote for it so that it will move higher up on the page!), but I thought I'd post an answer with some supplementary material that I think is useful.
Here is a Grammarphobia blog post on the subject: A pronouncing primer.
Relevant quotations:
The word for the elementary textbook was pronounced with a short “i”
(rhyming with “trimmer”) when it first showed up in English in the
14th century.
Americans still pronounce it that way. But in the late 19th century,
the British began pronouncing it with a long “i” to rhyme with “timer”
and that’s now the usual pronunciation in the UK, according to the
Oxford English Dictionary.
But English speakers on both sides pronounce “primer” with a long “i” (as in “timer”) when it’s used in other senses (such as an undercoat of paint or a cap used to ignite an explosive).
So, the pronunciation with a "long i" dipthong /aɪ/ is more recent, but both pronunciations exist in modern speech. All I would add is that, evidently, some Americans also rhyme the word with "timer" for all senses.
The earliest example for the textbook sense is from “The Prioress’s
Tale” in Chaucer’s Canterbury Tales (circa 1390): “This litel child
his litel book lernynge, / As he sat in the scole at his prymer.”
Side note: as far as I know, the spelling in this example is consistent with either pronunciation; that is, the Middle English spelling "prymer" is ambiguous about vowel length. A single vowel letter before a single intervocalic consonant could in general correspond to either a "short" or "long" vowel in Middle English pronunciation—for example, a common spelling of "ridden" in manuscripts of Chaucer is "riden"—and I believe "y" could in general correspond to either the long or short pronunciation of "i" (for example, "living" is spelled "lyuyng"). Apparently the use of "y" for "i" in Middle English was especially common next to the letter "m" or "n" (as in "hym" for "him") and here the letter comes before "m" (Complete Works Of Geoffrey Chaucer, W.W. Skeat).
The spelling does suggest a long vowel to a modern English speaker's eye, but does no more than suggest it: many words like body, camel, lemon and model have short vowels before single intervocalic consonant letters. Heck, the word gamut is spelled with a single "m" even though based on the etymology and pronunciation it "should" have two! Modern English spelling doesn't perfectly reflect either current pronunciation or historical pronunciation (or etymology, for that matter).
Etymological considerations don't tell us how to pronounce the word
Primer is etymologically related to prime, but alternations in vowel length are common in etymologically related words. Another word related to these two with a short /ɪ/ is primitive. More distantly related are prince and principal, which aside from having /ɪ/, also show a change of m to n before the consonant c.
So, just why is the vowel traditionally "short"?
Moving on to the actual question: why does the historical pronunciation have /ɪ/? It's a difficult question, which is probably why none of the previous answers have really addressed it.
I don't have enough knowledge to confidently state the answer, so all that follows is just speculation. However, I will reference facts I found that seem relevant.
First, the general tendency in English for vowels to be "long" when written before a single consonant followed by another vowel seems to stem from the historical process of open syllable lengthening. Here is Wikipedia's description of the process:
Around the 13th century, short vowels were lengthened in an open
syllable (i.e. when followed by a single consonant that in turn is
followed by another vowel). In addition, non-low vowels were lowered:
/i/ > /eː/, /e/ > /ɛː/, /u/ > /oː/, /o/ > /ɔː/. This accounts, for
example, for the vowel difference between staff and the alternative
plural staves (Middle English staf vs. stāves, with open-syllable
lengthening in the latter word). This process was restricted in the
following ways:
- It did not occur when two or more syllables followed, due to the
opposing process of trisyllabic laxing.
- It only occasionally applied
to the high vowels /i/ and /u/, e.g. OE wudu > ME /woːd/ > wood; OE
wicu > ME /weːk/ > week. Most instances of /i/ and /u/ remained as
such, e.g. OE hnutu > NE nut, OE riden > NE ridden.
The effects of open-syllable lengthening and trisyllabic laxing often led to differences in the stem vowel between singular and plural/genitive. Generally these differences were regularized by analogy in one direction or another, but not in a consistent way:
- ME path, pāthes > NE path, paths, but ME whal, whāles > NE whale, whales
- ME crādel, cradeles > NE cradle, cradles, but ME sādel, sadeles > NE saddle, saddles
The Oxford English Dictionary's earliest citation for primer is from the fourteenth century, in 1378; unfortunately, I'm not sure how open syllable lengthening applied in that time. Anyway, one interesting point here is the note about how open syllable lengthening generally did not apply to short /i/. This brings up a new question: when the word "primer" entered English, was the vowel short, or long?
If the word came through French, the vowel would probably be expected to be short
On the one hand, some French words spelled with I were imported, at some time before the Great Vowel Shift, with long /iː/: for example, tiger and cider. However, I think this was mainly a thing for I that occurred before a final syllable containing the vowel schwa (for example, the antecedent French forms of these two words are tigre and sidre/cidre, ending in "e muet" which was originally pronounced as a schwa in French).
In the Anglo-Norman form that the OED mentions, primer, the syllable with the I would have come before a syllable pronounced with an unreduced vowel in French (English speakers tend to hear such syllables in French as "stressed" when they occur at the end of a prosodic phrase). The vowel would therefore be expected to be short; for comparison, we see a "short" vowel in the first syllables of chisel (which the OED says is from "Old Northern French chisel (= central Old French cisel, in modern French ciseau"), vigil (from French vigile), and river (which the OED says is from "Anglo-Norman rivere, river, riveir, rivier, rivre, revere, rievere"). You can see other similar examples in Jespersen's Modern English Grammar, §3.112.
If the word came through Latin, the vowel wouldn't necessarily have been long
The OED says that the Latin etymon is primarius. Although (as Janus Bahs Jacquet said in a comment below) this word had a "long" /iː/ in Classical Latin, contrastive vowel length was lost in the traditions of pronouncing Latin that had the most influence on English pronunciation. A system of non-contrastive vowel length based on the position of the stress came to be used instead.
The word primarius has stress on the second syllable. Because the first syllable is unstressed, I think English speakers of the relevant time periods might have pronounced the I as short, although I'm far from certain of this (Jespersen (§4.66) actually suggests that at one point, it was regular for vowels in pre-tonic syllables to be lengthened in the "schoolboy" English pronunciation of Latin; however, I don't know to what extent this would have been applied to words that passed into common use).
In any case, the modern English pronunciations of words from Latin sometimes have "unexpected" short vowels, e.g. syrinx has /ɪ/ instead of /aɪ/ in the first syllable. I don't think the Latin etymology of primer clearly points to any one particular pronunciation of the I in the first syllable (particularly because, as Janus Bahs Jacquet notes, the English form shows other divergences from the Latin one, such as the use of E instead of A in the second syllable).
If the word did originally have a long vowel, it might possibly have been shortened by English sound changes
Alternately, if it did originally have long /iː/ in Middle English, the Wikipedia quote describes another process by which it might have been shortened to /i/: trisyllabic laxing, which apparently would occur in forms like the plural *primeres (hypothetical; I don't know that this form actually existed) and then be generalized to the singular.
In a way, the spelling is stranger than the pronunciation: there are a number of words in English that have unetymologically doubled consonants after a short vowel (such as pillar, summer, hammer, stammer, ridden), but although double mm was used in the past to spell primer, the single-consonant spelling won out for some reason. This allowed the spelling pronunciation /praɪmər/ to eventually become established.
Bibliography
Jespersen, Otto. A Modern English Grammar on Historical Principles, Part I: Sounds and Spellings. 1961.