It is hard to study something people don’t want to talk or hear about
Many of the historical medical writers included sexuality in their discussion. There were also erotic collections (or pornography if you will) and a lot of negative writing on masturbation beginning in the 18th century. Little of this could be called research but there are many advice manuals et al. This picked up in the nineteenth century as the reading public expanded.
More...