mid-15c., "act or process of testing, a putting to proof by examination, experiment, etc.," from Anglo-French trial, noun formed from trier "to try" (see try (v.)). Sense of "examining and deciding of the issues between parties in a court of law" is first recorded 1570s; extended to any ordeal by 1590s.
As an adjectival phrase, trial-and-error is recorded from 1806. Trial balloon (1826) translates French ballon d'essai, a small balloon sent up immediately before a manned ascent to determine the direction and tendency of winds in the upper air, though the earliest use in English is figurative.