The practice of S&M was around long before it was publicized in novels. For example, in 1498, the philosopher Pico della Mirandola wrote about an instance where a man needed to be whipped before sex occurred.
A German physician, Johann Heinrich Meibom, developed the first theory of masochism. He believed that being beaten on the back warmed the semen and caused it to drop to the testicles, which resulted in sexual arousal. Later, in 1788 this theory was modified by Francois Amedee Doppet to include women because he observed that women had warm vaginas after being whipped. Thankfully, our knowledge of anatomy has increased greatly since those ancient ways of thinking!