Althaea officinalia (the "marsh mallow") is a perennial that grows wild in salty marshes. Egyptians discovered that the root contained a sweet sap that could be used to sweeten cakes. The delicacy was reserved for Pharaohs.
The Greco-Roman world embraced the substance in mallows and believed it had medicinal value. The 1st century Dioscorides (cribbing from Pliny) wrote:
boiled in ... wine or chopped on its own, it works against wounds, tumors of the parotid gland[*], swellings in the glands of the neck, abcesses, inflamed breasts, inflammations of the anus, bruises, swellings, tensions of the sinews ... It works also against dysentery, blood loss and diarrhoea. [Hippocratic Recipes: Oral and Written Transmission of Pharmacological Knowledge in Fifth- and Fourth-century Greece, p.264]Medieval Europe, willing to try anything suggested by the Classical world, discovered how sweet the mallow concoctions were and started using them as a sweet treat—with the bonus of them being healthful. An Italian cookbook of the 1400s—De Honesta Voluptuate et Valetudine [On Right Pleasure and Good Health], by Bartolomeo Platina—suggested several ways to season the substance. Medieval monks grew the mallow for its sweetness and medical properties. Herbalists turned it into treatments for sore throats and coughs, indigestion and toothache.
The marshmallow sap was used for liquids in the Middle Ages; it was 19th century French confectioners who whipped it into a solid candy by mixing it with egg whites and corn syrup. Nowadays it can be made without any recourse to the mallow plant. My personal favorite recipe is here (you would be surprised how easy it is to make, and how sticky it is to work with after it has "set"). If you would rather make it from actual marshmallow root, go here.
*The "parotid gland" is a salivary gland in the back of the mouth.