"Knight in shining armor" is an idiomatic English expression describing a heroic rescuer. The term has its roots in romantic depictions of knighthood in the Middle Ages, particularly stories and poems relating to the legendary British hero King Arthur. This expression seems to have originated in the late 18th century, if not before, although its figurative meaning became more common during the 19th century. It is equally common in both British and American English, although the British spelling of "armor" is "armour."
The first recorded version of the phrase occurs in a 1790 satirical poem by English poet Henry Pye. Pye's poem contains the phrase "the knight, in shining armour dress'd." Although this may be the origin of the phrase, at this point it is simply a description of an idealized age of chivalry rather than a stock phrase. Pye's poem, however, relied on the romantic associations which would make the saying popular.
The term "knight" derives from "cnicht," an Old English word which originally meant nothing more than a young man. By the Middle Ages, however, it had become the English equivalent of the French "chevalier," a term which likewise originally meant only a horseman but came to have more complicated social meanings. "Knight" came to indicate a social class, as well as the virtues of chivalry. Chivalry was a code of behavior under which knights were expected to demonstrate courage, courtesy, piety, generosity and other virtues. Medieval literature portrayed knights not only as warriors, but also as heroic defenders of the innocent and paragons of virtue, an image which experienced a revival in the Romantic art and literature of the 19th century.
This romantic conception of chivalry lies behind the expression. The person described as a "knight in shining armor" is being characterized as a heroic rescuer. This can be the case even in small matters. A person who brings a coworker a cup of coffee at a crucial moment might be described as a "knight in shining armor." The comparison expresses gratitude in a slightly exaggerated way, using comedy to defuse the minor social awkwardness involved.
"Knight in shining armor" is often used as a negative comparison. Many modern speakers see the image of the chivalrous hero as a corny stereotype, an unrealistic standard for the complexities of real life. "I may not be a knight in shining armor..." is a common form of negative comparison.