The legal usage is a specific, jargon-determined version of damage that has an etymon in Latin.
The semantic connection between damage as loss and damage as compensation for damage goes back to both French and Latin, languages that early English lawyers would have known well. For instance, English only became the official language of English law in 1650; before that, much of English law was also dependent on older laws and rulings written in Latin or French, languages that were used because they were thought to be more precise and authoritative on legal matters (Dale Barleben, "Legal Language, Early Modern English and Their Relationships").
This was true even in Latin, where according to Lewis and Short the etymon damnum could mean harm or loss
I.hurt, harm, damage, injury, loss
as well as legal penalty:
II. Esp. in law.
A. A fine, mulct, penalty [...] 1. damnum injuria (datum), i. e. an injury done to another's beast or slave, for which the lex Aquilia provided compensation,
The lex Aquilia was a 3rd century BCE Roman law that granted payment for injury or loss to property caused by someone else (Wikipedia). This law provided the basis for attempting to quantify the damnum (the damage to property) in a legal proceeding in order to calculate the damnum injuria datum (the damages to be given).
The legal story of how the lex Aquilia influences French law and English common law is complicated (see e.g. "How the Romans Did for Us: Ancient Roots of the Tort of Negligence"), but in summary, the foundational legal terms were taken up successively in French courts and then in English ones. The legal damnum became damages in English law (via the French damage), while the more general meaning of damage also came into English. For instance, Geoffrey Chaucer and John Lydgate, two Middle English authors who would have been familiar with French, Latin, and Chancery English, serve as early examples of the use of damages in the OED:
c1374 G. Chaucer tr. Boethius De Consol. Philos. i. v. 25 Þou hast wepen for þe damage [1560 dommage] of þi renoune þat is appaired.
1430 J. Lydgate tr. Hist. Troy i. vi He was enoynted with an oyntment On his body that kept him from damage.
That entanglement of general and legal use continued into the early modern period and beyond. Early lexicographers parsed the two meanings in ways that explained the legal sense as an extension of the general one. For example, John Cowell, in The Interpreter: or Book Containing the Signification of Words (1607) attempts to parse the distinction between the general meaning of hurt or loss and its legal use:
DAmmage , commeth of the french (dam) or (domage) signifiing generally any hurt or hinderance, that a man taketh in his estate: But in the common lawe, it particularly signifieth a part of that the Iurours be to inquire of, passing for the plaintiffe or demandant in a ciuile action, be it personall or reall. For after verdict giuen of the principall cause, they are likewise asked their consciences touching costs (which be the charges of suite, called of the Civilians (expensæ litis) and dammages, which conteine the hindrance that the plaintiffe or demandant hath suffered by meanes of the wrong done to him by the defendant or tenent.
So in Cowell's explanation, damage generally refers to hurt or hindrance, whereas the legal damages are an estimate of the specific hindrance done to the plaintiff that the defendant may be liable to pay.