In ancient Rome, purple was the color of royalty, a designator of status. And while purple is flashy and pretty, it was more important at the time that purple was expensive. Purple was expensive, because purple dye came from snails.

The video above, by CreatureCast, recounts the story of Rome’s vaunted Tyrian purple, and the color’s close link with the marine snail Bolinus brandaris. The New York Times:

To make Tyrian purple, marine snails were collected by the thousands. They were then boiled for days in giant lead vats, producing a terrible odor. The snails, though, aren’t purple to begin with. The craftsmen were harvesting chemical precursors from the snails that, through heat and light, were transformed into the valuable dye.

But this telling leaves out one of the best parts of the story.

The video explains that snail-fueled purple persisted until chemists learned to make synthetic dyes. But the development of an artificial purple wasn’t a deliberate decision, but a happy accident for a young chemist named William Henry Perkin.

In the 1850s the British Empire was pushing into Africa. The Empire’s colonization attempts, though, were being beaten back by malaria. Scientists had recently realized that quinine, a chemical derived from the bark of cinchona trees, could be used to treat against malaria. But cinchona trees come mostly from South America, and scientists wanted a better way to get their hands on the drug.

Enter William Perkin, a young chemist who had joined the Royal College of Chemistry at 15. In 1856 Perkin, now 18, was trying to synthesize quinine in the lab. After repeated failures, “Perkin produced little more than a black, sticky mess,” says the Independent. Trying to dissolve his gunk in alcohol, though, revealed a deep purple liquid.

Perkin’s purple, otherwise known as aniline purple, or mauveine, was the first synthetic dye. The synthesis transformed purple’s elite status, and probably saved the lives of a great many snails.

More from Smithsonian.com:

In 2010, Malaria Killed 660,000 People, And Now It’s Resistant to the Drugs We Use to Fight It