late 14c., "relating to civil law or life; pertaining to the internal affairs of a state," from Old French civil "civil, relating to civil law" (13c.) and directly from Latin civilis "relating to a society, pertaining to public life, relating to the civic order, befitting a citizen," hence by extension "popular, affable, courteous;" alternative adjectival derivative of civis "townsman" (see city).
Meaning "not barbarous, civilized" is from 1550s. Specifically "relating to the commonwealth as secularly organized" (as opposed to military or ecclesiastical) by 1610s. Meaning "relating to the citizen in his relation to the commonwealth or to fellow citizens" also is from 1610s.
The word civil has about twelve different meanings; it is applied to all manner of objects, which are perfectly disparate. As opposed to criminal, it means all law not criminal. As opposed to ecclesiastical, it means all law not ecclesiastical: as opposed to military, it means all law not military, and so on. [John Austin, "Lectures on Jurisprudence," 1873]
The sense of "polite" was in classical Latin, but English did not pick up this nuance of the word until late 16c., and it has tended to descend in meaning to "meeting minimum standards of courtesy." "Courteous is thus more commonly said of superiors, civil of inferiors, since it implies or suggests the possibility of incivility or rudeness" [OED].
Civil, literally, applies to one who fulfills the duty of a citizen; It may mean simply not rude, or observant of the external courtesies of intercourse, or quick to do and say gratifying and complimentary things. ... Courteous, literally, expresses that style of politeness which belongs to courts: a courteous man is one who is gracefully respectful in his address and manner — one who exhibits a union of dignified complaisance and kindness. The word applies to all sincere kindness and attention. [Century Dictionary, 1895]
Civil case (as opposed to criminal) is recorded from 1610s. Civil liberty "natural liberty restrained by law only so far as is necessary for the public good" is by 1640s.