Origins
Sample and example are the same word.βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ Sample is what remains after the first syllable of example was lost β a process linguists call aphesis. Old French essample became sample through the same clipping that turned esquire into squire, escape into scape, and estate into state.
Both trace back to Latin exemplum, meaning 'a thing taken out' β from eximere, composed of ex- ('out') and emere ('to take, to buy'). A sample is, literally, something removed from a larger whole to represent it. The connection to buying is ancient: in Roman markets, you would take out a portion of grain to inspect before purchasing the lot.
The Latin emere, 'to buy or to take', has a rich family. Exempt means 'bought out' β freed from an obligation by payment or privilege. Redeem means 'bought back'. Premium is 'a price taken beforehand'. Vintage comes from Latin vindΔmia β 'a grape-taking', the harvest.
Latin Roots
In music, sampling β taking a portion of one recording for use in another β is the most literal modern application of the word's original meaning. A DJ samples the way a Roman merchant sampled grain: by extracting a piece that stands for the whole.
The sampler β a piece of decorative needlework β preserves yet another sense: a demonstration of skill, a specimen of what the maker can do.