Historical Erotic Art
Erotic art has always been a part of our visual culture, I guess the first images of nude people in, more or less, erotic poses were found on the walls of caves. And even though the nude was mostly functional ( used for rites, religion etc.. ) in those early days, there was definitely an erotic or sexual aspect.
Contemporary erotic art in perspective
The Ecstasy of St Theresa
Bernini just followed the description of the vision St. Theresa had. She describes her experience in rather sexual terms, here's a free translation of her vision.
"In his hands he had a large golden Spear and at the end of his spear was fire. With this spear he entered my body. When his spear was pulled out, he left the fire of God inside me. The pain I felt made me groan, but it was also sweeter then I could ever imagine. It was mostly spiritual, but the body had a mayor part in this experience."
I guess Bernini used this vision as an opportunity to create an erotic piece of art, not an easy thing to achieve in this religious dogmatic period. Sexuality was not something considered decent or good, it was a necessary part of human life restricted to a married couple, and you'll better not enjoy it, and surely not display it in public as art.