Google Khajuraho and you will come upon one of the UNESCO World Heritage Sites in India. The Khajuraho temples feature a variety of art work, of which 10% is sexual or erotic art outside and inside the temples. People describe it as "the apogee of erotic art." Why would the ancient Hindus depict these figures - does it have to do with their religion and tradition? What was the aim?
The Kamasutra likely holds some clues. At the very least, it demonstrates that sexuality was a topic covered in Vedic literature.
Puruṣārtha is a concept in Hinduism referring to the goals of human life. One of these goals is Kama which is a term for desire. Although Kama is not exclusively sexual desire, sexual desire a component.
The Kamasutra is widely misunderstood in that in the modern imagination it is regarded as a kind of sex manual as opposed to a religious text exploring the spiritual aspects of sensation and pleasures of the senses in general.
There is also a tradition of Tantric pursuits in Hinduism and, later, in Buddhism. Tantric practice, like the Kamasutra, is widely misinterpreted to be exclusively related to sexual rituals, although in fact Tantric practice connotes a wide array of esoteric practices. Nevertheless, sexual practice is one form of Tantric pursuit.
Although I, unfortunately, have only cursory knowledge of Hinduism, a tradition which is extraordinarily vast and varied, hopefully this answer will provide at least some insight.
First things first. I do not agree with Ken Graham's answer. It is incorrect. I shall shortly tell why.
The Shivling is a form in which Shiva/Mahadev is worshipped. The Shivling with Yoni
In the image you see the universal design for a Shivling. It always constitutes a Yoni. Now, this may be horribly scarring: the cylindrical figure there is called the lingam. In Hindi, it means 'Penis', while yoni means womb or vagina. *It is a representation of Shiva's penis and Shakti/Parvati's womb.
Now you may ask why Hindus worship such a thing. The reason is as follows.
Worship is done in two forms. With the outer fire, Agni, called yagna, or with the inner fire, Tapa, called Tapasya. The liquid of life is called Rasa. It exists in many forms. When a man completely stops the flow of rasa through himself, he ignites the inner fire, Tapa, and becomes a Yogi. Such a Yogi was Shiva. And when a most powerful demon broke through the ranks of Devas the celestial beings, who had gotten a boon that he could be killed by naught but a newborn child. And when Amravati the city of Indra fell to his hands, the Devas went to Shiva. Being deep in meditation he did not hear their pleas, but Shakti his consort assured them that help would come. And then Shakti lying down on top of the Mahadev inserted his lingam into her yoni, and immediately Shiva spit out his fiery seed. It was taken hold of by Agni the Fire God, who unable to bear its radiance handed it over to Ganga the holy river of cool waters. When her waters were unable to cool it down Ganga placed Shiva's radiant seed in the Sara forest. Here, the six Krittikas who were passing by were drawn to it by its radiance, and here it became Skanda. The Krittikas encaptured by the child's beauty nursed it, until Agni the Fire God and Ganga of the cool waters fought for him with them. Thus they went to Shakti Shiva's consort, upon seeing whom Skanda sprouted six heads to show his appreciation of the Krittikas. And Shakti said, "For you have been nursed by them you shall be called Kartikeya." And the newborn Kartikeya, being born of Shiva's seed, was most powerful, and leading the Devas to battle mounted on a peacock, holding a divine leaf-shaped spear, he inserted the spear into the Asura's stomach who could be killed only by a newborn even as the Devas fought with the Asura's lesser armies, thus bringing them victory. And hereforth he was crowned the God of War and Victory, and Commander of the Devas in Battle.
The main point I am trying to show here is that sexual acts were not frowned upon in Hindu Society.
Now, we know that temples were painted with scenes of Gods. So was the scene of the birth of Kartikeya painted. And then, they-did-it-we-will-too type of thinkng, and other factors led to the frequency of Sexual Imagery we see in temples today.
PS Another source of Sexual Imagery is Krishna, the eighth Avatar of Vishnu. There is a story about how he stole the clothes of bathing Gopis and made them stand naked, while eyeing them with only appreciation, no lust. This was because his actions were leela, neither virtue nor vice, and which did not leave records in Chitragupta's register.
All of the information here comes from
Myth=Mithya - Devdutt Pattnaik (Do not read this book! It will confuse you like hell before killing you in the middle of the night)
Jaya - An Illustrated Version of the Mahabharata - Devdutt Pattnaik
Sita - An Illustrated Version of the Ramayana - Devdutt Pattnaik
The Pregnant King - Devdutt Pattnaik
My Maternal Uncle
Why there are graphic depictions of sexual acts in some Hindu temples, especially the Khajuraho Group of Temples?
As in many cultures, sex has been considered sacred throughout the ages, the Hindu culture is no different.
Hinduism only approves the marital sex as sacred and prohibits premarital or extramarital sex. Some sects in Hinduism worship Yoni (female sex organ) as the Goddess. Hindus worship Lord Shiva in the form of Lingam, which is a symbol of male creative energy and is always shown with Yoni, the symbol of female creative energy. - Sex and Hinduism
As for why there are graphic depictions of sexual acts in some Hindu temples, in particular the Khajuraho Temples we could possibly have a reason as follows:
In Hinduism Dharma, Artha, Kama, and Moksha are the four Purusharthas of a Hindu’s life and sex is an integral part of life,which is part of the four Purusharthas. The “Kama” means those activities, which give us pleasure and satisfaction. Sex is also one of those activities which gives great pleasure and satisfaction.
Kamasutra is very ancient book about sex, written by the Hindu sage Vatsayana. This book has all those details and descriptions about sex types, sex positions, sex importance and compatibility of partners, eunuchs etc. The ancient Khajuraho Temple in Madhya Pradesh, India is well known for the sculptures on it. Here the statues of men and women are depicted as having sex in different positions. The builders of the Khajuraho temple were Rajputs and were followers of Waam-maarga or left-handed Tantra, an acceptable way of attaining Moksha.
The sculptors created those pieces of arts is only outside the temple because it signifies that all those feelings must be left outside the temple, before entering the inner sanctum. There are no such sculptures inside the temple. The sculptures are also on Konark temple’s exterior. It is a metaphysical symbolism. Hinduism recognizes the role of sexual desires in human lives.
The sexual depictions in some of the temples were mean to not only educate the people, but also to help those who were involved in sexual sadhanas for enlightenment. There is a difference between nudity and expression of beauty and pornography.What appears in Hindu puranas and Itihasas are the expressions of genuine beauty and not pornography.
The carving of such bold sculptors denotes the free thinking creative minority existing in India at that time.This also signifies that Scythians, Huns, and Kushans assimilation in Hindu society was complete by then. The freeness of the society towards discussing sex empirically and scientifically reveals about the overall openness of the culture. - Sex and Hinduism
Here is a video which shows many of the sexual or erotic art works in question: KHAJURAHO THE TEMPLE OF LOVE (YouTube).