"single as regards number, class, or kind," Middle English onli, from Old English ænlic, anlic "only, unique, solitary," literally "one-like," from an "one" (see one) + -lic "-like" (see -ly (1)). Similar formation in Old Frisian einlik, Dutch eenlijk, Old High German einlih, Danish einlig. It preserves the old pronunciation of one. Related: Onliness.
Its use as an adverb ("alone, no other or others than; in but one manner; for but one purpose") and conjunction ("but, except") developed in Middle English. Distinction of only and alone (now usually in reference to emotional states) is unusual; in many languages the same word serves for both. German also has a distinction in allein/einzig. Phrase only-begotten (mid-15c.) is biblical, translating Latin unigenitus, Greek monogenes; the Old English word was ancenned. Only child is attested by 1700.