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 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.