These principles derive initially from Plato in Republic Book IV, 426-435 (and see Protagoras 330b, which also includes piety (hosiotes)). Cicero expanded on them, and Ambrose, Augustine of Hippo, and Thomas Aquinas adapted them while expanding on the theological virtues.
The four cardinal virtues appear as a group (sometimes included in larger lists) long before they are later given this title.
Plato identified the four cardinal virtues with the classes of the city described in The Republic, and with the faculties of man. Plato narrates a discussion of the character of a good city where the following is agreed upon. "Clearly, then, it will be wise, brave, temperate [literally: healthy-minded], and just." (427e; see also 435b) Temperance was common to all classes, but primarily associated with the producing classes, the farmers and craftsmen, and with the animal appetites, to whom no special virtue was assigned; fortitude was assigned to the warrior class and to the spirited element in man; prudence to the rulers and to reason. Justice stands outside the class system and divisions of man, and rules the proper relationship among the three of them.
Plato sometimes (e.g., Protagoras 349b; cf. 324e, 329c, 330b, 331a-c) lists holiness (hosiotes, eusebeia, aidos) amongst the cardinal virtues. He especially associates holiness with justice, but leaves their precise relationship unexplained.
In Aristotle's Rhetoric we read: "The forms of Virtue are justice, courage, temperance, magnificence, magnanimity, liberality, gentleness, prudence, wisdom." (Rhetoric 1366b1)
The Roman philosopher and statesman Cicero (106-43 BC), like Plato, limits the list to four virtues:
"Virtue may be defined as a habit of mind (animi) in harmony with reason and the order of nature. It has four parts: wisdom (prudentiam), justice, courage, temperance." (De Inventione, II, LIII) 
Cicero discusses these further in De Officiis (I, V and following).
The Roman Emperor Marcus Aurelius discusses these in Book V:12 of Meditations and views them as the "goods" that a person should identify in one's own mind, as opposed to "wealth or things which conduce to luxury or prestige."
The cardinal virtues are listed in the Bible. The deuterocanonical book Wisdom of Solomon 8:7 reads, "She [Wisdom] teaches temperance, and prudence, and justice, and fortitude, which are such things as men can have nothing more profitable in life."
They are also found in the Biblical apocrypha. 4 Maccabees 1:18-19 relates: "Now the kinds of wisdom are right judgment, justice, courage, and self-control. Right judgment is supreme over all of these since by means of it reason rules over the emotions."
Catholic moral philosophy drew from all of these sources when developing its thought on the virtues.
Ambrose (AD 330s-397) was the first to use the expression "cardinal virtues." "And we know that there are four cardinal virtues temperance, justice, prudence, fortitude." (Commentary on Luke, V, 62)
Augustine of Hippo, discussing the morals of the church, described them:
For these four virtues (would that all felt their influence in their minds as they have their names in their mouths!), I should have no hesitation in defining them: that temperance is love giving itself entirely to that which is loved; fortitude is love readily bearing all things for the sake of the loved object; justice is love serving only the loved object, and therefore ruling rightly; prudence is love distinguishing with sagacity between what hinders it and what helps it. (De moribus eccl., Chap. xv)
The "cardinal" virtues are not the same as the three theological virtues: Faith, Hope and Charity (Love), named in 1 Corinthians 13. And now these three remain: faith, hope and love. But the greatest of these is love. Because of this reference, a group of seven attributes is sometimes listed by adding the four cardinal virtues (prudence, temperance, fortitude, justice) and three theological virtues (faith, hope, charity). Together, they compose what is known as the seven virtues. While the first four date back to Greek philosophers and were applicable to all people seeking to live moral lives, the theological virtues appear to be specific to Christians as written by Paul in The New Testament.
Efforts to relate the cardinal and theological virtues differ. Augustine sees faith as coming under justice. Beginning with a wry comment about the moral mischief of pagan deities, he writes:
They [the pagans] have made Virtue also a goddess, which, indeed, if it could be a goddess, had been preferable to many. And now, because it is not a goddess, but a gift of God, let it be obtained by prayer from Him, by whom alone it can be given, and the whole crowd of false gods vanishes. For as much as they have thought proper to distribute virtue into four divisions - prudence, justice, fortitude, and temperance - and as each of these divisions has its own virtues, faith is among the parts of justice, and has the chief place with as many of us as know what that saying means, 'The just shall live by faith.' (City of God, IV, 20)
Dante Alighieri also attempts to relate the cardinal and theological virtues in his Divine Comedy, most notably in the complex allegorical scheme drawn in Purgatorio XXIX to XXXI. Depicting a procession in the Garden of Eden (which the author situates at the top of the mountain of purgatory), Dante describes a chariot dragged by a gryphon and accompanied by a vast number of figures, among which stand three women on the right side dressed in red, green and white, and four women on the left, all dressed in red. The chariot is generally understood to represent the holy church, with the women on left and right representing the theological and cardinal virtues respectively. The exact meaning of the allegorical women's role, behaviour, interrelation and color-coding remains a matter of literary interpretation.
Later, in the High Middle Ages, some authors opposed the seven virtues (cardinal plus theological) to the seven capital sins. However, "treatises exclusively concentrating on both septenaries are actually quite rare." and "examples of late medieval catalogues of virtues and vices which extend or upset the double heptad can be easily multiplied."  And there are problems with this parallelism.
The opposition between the virtues and the vices to which these works allude despite the frequent inclusion of other schemes may seem unproblematic at first sight. The virtues and the vices seem to mirror each other as positive and negative moral attitudes, so that medieval authors, with their keen predilection for parallels and oppositions, could conveniently set them against each other. . . . Yet artistic representations such as Conrad's trees are misleading in that they establish oppositions between the principal virtues and the capital vices which are based on mere juxtaposition. As to content, the two schemes do not match each other. The capital vices of lust and avarice, for instance, contrast with the remedial virtues of chastity and generosity, respectively, rather than with any theological or cardinal virtue; conversely, the virtues of hope and prudence are opposed to despair and foolishness rather than to any deadly sin. Medieval moral authors were well aware of the fact. Actually, the capital vices are more often contrasted with the remedial or contrary virtues in medieval moral literature than with the principal virtues, while the principal virtues are frequently accompanied by a set of mirroring vices rather than by the seven deadly sins.
Jesuit scholars Daniel Harrington and James Keenan in their Paul and Virtue Ethics (2010) argue for seven "new virtues" to replace the classical cardinal virtues in complementing the three theological virtues, listed as "be humble, be hospitable, be merciful, be faithful, reconcile, be vigilant, and be reliable", although they don't explain why it has to be an either/or matter of replacing the cardinal virtues rather than supplementing them.
The Cardinal Virtues are often depicted as female allegorical figures and were a popular subject for funerary sculpture. The attributes and names of these figures may vary according to local tradition.
In many churches and artwork the Cardinal Virtues are depicted with symbolic items:
|Iustitia (justice)||Fortitudo (fortitude)||Prudentia (prudence)||Temperantia (temperance)|
Allegories of the virtues on the facade of the Gesuati church in Venice (1737)
Allegories of the virtues on the facade of La Rochelle city hall