Today the word 'masterpiece' refers to a creation that has received high critical acclaim—especially one that is considered one of the greatest works of a person's career and has required extraordinary creativity, skill, or workmanship.
In the old European guild system, however, the term 'masterpiece' was used to refer to a piece of work made or created by an apprentice or journeyman working towards becoming a master craftsman.
The masterpiece was judged, and if successful, it was kept by the guild. It was therefore very important to produce a piece of very high quality in whatever the apprentice's craft was, whether it was confectionery, painting, goldsmithing, knifemaking, or any other trade.
The Royal Academy in London has acquired an impressive collection of "diploma works" as a condition of acceptance into guilds. Originally the paper which a student needed to present in order to have gained the distinction of 'Master of Arts' was also referred to as a 'masterpiece.' In other words, it was a fine piece of scholarship in the particular craft which the student sought to be admitted into as a master craftsman.
The term probably derives from the original Dutch word 'meesterstuk' (in German it is Meisterstck), whereas 'masterpiece' is first found in English in 1605.