The word 'example' traces back to the Roman practice of pulling a single item from a larger group to serve as a representative specimen. It comes from Latin 'exemplum,' meaning 'a sample, a model, a pattern, a precedent, an instance,' from the verb 'eximere' — 'to take out, to remove' — composed of 'ex-' (out) and 'emere' (to take, to buy, to obtain).
The Latin verb 'emere' originally meant simply 'to take,' and it acquired the commercial sense of 'to buy' because buying is a particular kind of taking. From 'emere' and its compounds, English has inherited a diverse family: 'exempt' (taken out of an obligation), 'redeem' (to buy back, from 'red-' + 'emere'), 'premium' (the price taken first), 'peremptory' (taking away entirely), and through other paths, 'assume,' 'consume,' 'presume,' and 'resume.' The PIE root *em- (to take) is the silent engine behind all of them.
In classical Latin, 'exemplum' had a rich range of uses. It could mean a physical sample of goods, a pattern to be copied, a legal precedent, or — in the rhetorical tradition — an illustrative anecdote drawn from history or mythology. Cicero and Quintilian used 'exempla' extensively in their orations and handbooks: a well-chosen 'exemplum' from Roman history could clinch an argument more effectively than abstract reasoning. This rhetorical tradition continued through the Middle Ages, when preachers filled their sermons with 'exempla' — moralizing stories drawn from saints' lives, classical history, and folklore — and gave rise to whole collections
The word entered English via Old French 'essample' or 'example' around 1386 (Chaucer uses both forms). The initial vowel varied considerably in Middle English — 'ensaumple,' 'exaumple,' 'essample' — reflecting the instability of the prefix as it passed through different dialects of French.
One of the most interesting facts about 'example' is that it has a twin: 'sample.' Both words descend from Latin 'exemplum,' but they arrived in English by different routes. 'Example' came through the learned, Latinate channel, preserving the prefix 'ex-.' 'Sample' came through popular spoken French, where 'essample' lost its initial unstressed syllable and became 'sample.' Such doublets — pairs of words from the same source that diverged in form and meaning — are a characteristic feature of English, which draws from both learned and popular strands of French. In this case, 'example'
The phrase 'to make an example of' — meaning to punish someone publicly as a warning to others — preserves the Roman legal sense of 'exemplum' as a precedent or cautionary instance. 'Exemplary' can mean both 'serving as a desirable model' and 'serving as a warning' (as in 'exemplary punishment'), and these two senses — the model to emulate and the cautionary tale to avoid — have coexisted since Latin.
The modern computing usage of 'example' in documentation ('for example,' abbreviated 'e.g.' from Latin 'exemplī grātiā,' 'for the sake of an example') continues the ancient rhetorical function: a concrete instance that makes an abstract principle comprehensible. The word has traveled from the Roman marketplace to the medieval pulpit to the modern codebase, but its core meaning — something taken out to stand for the whole — has remained remarkably stable across two millennia.