The codpiece, for the uninformed, was an article of clothing worn widely in Europe during the Renaissance. It obscured the male's nether region, which was uncovered by the pants of the era. It was often padded and even bejeweled to draw the eyes of the viewer to it. Later on, the style was to simulate a permanent erection, signifying virility to the onlooker, especially important in those days of syphilis and inbreeding among the nobility.
Its humble beginnings
The codpiece developed out of necessity. You see, the standard outfit worn by males of the day, at least among the upper classes, consisted of a shirt, a doublet, which was a short coat, and hose or pants. No underwear. And the pants popular at that time were extremely tight, making it a difficult, time-consuming procedure to take them off. So they were crotchless, not covering the genitals at all, allowing one to go to the bathroom easily. The junk was covered by the length of the coat, and all was well.
However, as the Renaissance began, fashion started to lean towards shorter and shorter doublets. The waist moved lower but the hem moved much higher, showing more of the legs and suggesting a longer torso, which gave the illusion of greater height. Eventually, the skirt-like bottom of the doublet (it was belted at the waist) became little more than a fringe, totally revealing the genitalia. This was actually the fashion for a brief period - the penis was placed on display. This displeased the church of course, but at first the nobles ignored pious admonishments. Eventually the style moved into the merchant classses, and finally to the peasantry. However, the nobles felt threatened at the sight of the phalluses of the general public (one might speculate that this fear came from the frequent infertility of noblemen). Eventually, they began to heed the advice of the church, and began to wear the codpiece to obscure their manhood.
Its evolution
At first, the codpiece was simply a cloth bag, quite tight, tied at the top. This was worn by the nobles to avoid obscuring their masculinity too much, instead of (say) wearing pants that actually closed, or wearing long coats again. During the reign of England's Edward III, the codpiece assumed even more, um, prominence. Edward III's reign fell during the Hundred Years War and he encouraged his soldiers to enhance their packages to intimidate their French enemies. Reportedly, it worked, and this led to the new fashion of the era - stuffing your codpiece with cotton (called bombast, which led to the later meanings of the word) or almost anything else to enhance it.
The codpiece was most popular in England, most remarkably with the reign of Edward IV beginning in 1461. Edward IV was young, and said to be the most handsome man in Europe. He wore the codpiece, which had been eschewed by his more pious predecessors. His restoration of prosperity and power to England led to increased attention to fashion among the English; the young king, proclaiming his virility with his clothes, was popular and his style of dress was extremely influential throughout Europe.
The next step in their evolution came about in Spain, after the Reconquista, in which Spain was reunified, and began to achieve a place as the world's leading naval power. During its wars with England, during which it maintained a decided advantage until the Protestant Wind decided the final battle, confident nobles began to decorate themselves - designing their codpieces to simulate the appearance of a permanent erection to proclaim their puissance to the world. This permanent excitement became de rigeur for royalty all over Europe.
The end
The fall of the codpiece may primarily be ascribed to two rulers of the era: Elizabeth I of England and Henry III of France. A woman on the throne, of course, denied the nobility the example of a monarch who wore the thing. And Elizabeth, with her widely proclaimed (if not factual) virginity, did not encourage such license among the nobles. Henry, on the other hand, was gay, which, although seemingly common among royalty, especially the French of course, was not popular during the period. To hide it, he discouraged the display of cock, even hidden behind a codpiece, among the nobles. Henry, in fact, popularized a highly feminine costume, featuring jewelry and decoration, and eschewing the exhibition of the codpiece.
Thus, during the 16th century, the codpiece faded into oblivion, although it has been somewhat rescued of late. Both fetishists and Society for Creative Anachronism types still wear the codpiece today. They can still be purchased from specialty shops; check out a search engine if you're interested.
Interesting facts
People assume that the word codpiece has some sort of metaphorical connection to the fish with the same appellation. Not so. Codd was a Middle English word meaning bag, used as a euphemism for the scrotum.
A story attributed to England's Anne Boleyn: Duke Fabrizio of Bologne was visiting England and his audience was granted at an inopportune time. He was in his room, romancing a woman when he was called for. He dressed quickly, but his anatomy was uncooperative; he visited the king and queen with a visible erection. Queen Anne, perhaps initiating the modern phrase, asked "Be that thine codling or art thou glad to see me?" Codling referred to an elongated cooking apple. The king was apparently envious; he declared that "My codpieces must compare favorably to Bologna" which may or may not have been really funny at the time. His tailors complied; this led to further increase in the size of the codpiece. Actually, if modern sales of penis enlargers and such are any indication, one must imagine that codpieces were quite the object of competition, being that it's so much easier to enlarge your clothes than your dick.
Both of the factoids reference 'Briefe History of the Codpiece', http://www.onr.com/user/steveh/cods.htm, although I have heard them from other sources. However, the second seems very likely apocryphal to me, so repeat at your own risk.