Yes, a dentist co-invented it.
Spun sugar existed long before, but it was made by hand and was expensive. In 1897, William Morrison, a dentist from Nashville, Tennessee, and candy maker John C. Wharton patented an electric machine that melted sugar and used centrifugal force to spin it through tiny holes. The sugar cooled into fine threads that piled up like cotton.
They called it "Fairy Floss" and introduced it at the 1904 St. Louis World's Fair, where they sold tens of thousands of boxes. The irony of a dentist inventing a pure-sugar treat has made it a favorite trivia fact.
Another dentist, Josef Lascaux of New Orleans, later developed a similar machine, and the name "cotton candy" became common in the 1920s. In Britain it's called candy floss, and in Australia it's still fairy floss.
Cotton candy is mostly air. A big, fluffy serving often contains only an ounce or so of sugar, less than many people expect from its size.