Frankly, BDSM is as old as intercourse. This closed-door culture has its roots in Mesopotamia, where the Goddess of Fertility, Inanna, whipped her human subjects and caused them to do a frenzy dance. This painful whipping caused intercourse and led to pleasure amidst the dance and the moans.
The ancient Romans also believed in flogging, and they had a Tomb of Flogging where women flogged each other to celebrate Bacchus or Dionysus, the God of Wine & Fertility.
Besides, the ancient scriptures of the Kama Sutra also explain the practice of biting, slapping, gnawing, etc.
Furthermore, throughout the middle ages, flagellation was popular and was based on the idea of extreme love and passion. It was also believed to help people get rid of evils and sins.
Towards the 18th and 19th century, Marquis de Sade produced literary works that were full of aggression and violence. His works were often described as sadistic.
In addition, Venus in Furs, written in 1869 by Leopold von Sacher-Masoch, Fanny Hill (also known as Memoirs of a Woman of Pleasure) by John Cleland in 1748, enabled a strong sexual culture.
Going forward, in the early 20th century, roughly around the 1940s and 1950s, the publication of sex magazines gave the world exposure to leather, corsets, high heels. The pictures showed women wearing latex dresses with hands cuffed behind them as they are being beaten.
What BDSM is currently was also prevalent in every era,, and with the passage of time, more social connectedness, more exposure, and with the courtesy of the internet, people sharing such interests united and spread the culture further.