A detail is a piece cut off for inspection. The word comes from French détailler — 'to cut into pieces' — from dé- ('apart') and tailler ('to cut'), ultimately from Latin tālea meaning 'a cutting, a rod'.
The cutting metaphor is precise. When you examine something in detail, you are — etymologically — slicing it into pieces small enough to study. The whole is too large to comprehend at once, so you cut it apart. French artists in the 17th century spoke of details as the small elements separated from a composition for analysis, and English borrowed the word in this sense.
The Latin tālea generated a family of English words united by cutting. A tailor cuts cloth. Retail means 'to cut again' — a retailer buys in bulk and cuts the goods into smaller lots for individual sale. Curtail means 'to cut short'. Entail, in its legal sense, cuts an inheritance into a fixed line of succession.
The military borrowed the word too. A detail of soldiers is a small group cut from the main body for a specific task. The verb 'to detail' someone to a duty preserves this sense: you separate them from the whole and assign them to a part.
Tally may also belong to this family. A tally stick was a rod cut with notches to record debts — a tālea in its most literal sense. The detail and the tally share a common ancestor in a Roman cutting.