The purpose of a religion is basically to pave a way for leading a meaningful, smooth and joyous life without sacrificing mental peace and without too much pain and suffering.
Hinduism which is sanatana dharma — the way of righteous living contains more than enough guidelines for the above purpose.
Hindhu dharma outlines four Purusharthas — meaningful pursuits for life: Dharma, Artha, Kama & Moksha.
Righteousness and duties in life. Hinduism places highest importance to following righteousness in life. Whatever be your activity in life, if it confirms to right dharma, it brings in peace and harmony in life. The Hindu dharma does not permit an unbridled life of carefree enjoyment; everything has its preset boundaries. ‘Eat, drink and be merry’ is never considered the goal of life. Every individual is bound by his duties and responsibilities towards his family, to the society, to the nation and to the entire nature and universe even encompassing the departed souls of forefathers and devatas (demigods controlling the nature) in the upper worlds. In ancient Hindu civilization, Manu Smriti was the scripture elaborating the dharmas to be followed in life by different classes of people.
Going in pursuit of money, wealth, comforts and possessions is indeed considered as an essential aspect of human life. But it shall not be the only goal of life and whatever one does to acquire Artha should be bound by dharma. Else, one is sure to end up in a chaotic life of suffering.
Seeking pleasure through the 5 senses including sexual pleasure is the very nature of all creatures. Again Hinduism permits enjoyment within boundaries. Any hunt for joy ignoring dharma is highly discouraged because such a pursuit may bring short term joy but end up in pain in the long run.
Of all the acceptable pursuits of life, seeking Moksha (liberation from the Samsara — from the cycle of births and deaths) is considered the highest goal of life. Man, after pursuing a life of seeking artha (wealth) and kama (pleasures) and even leading a life of strict dharma (righteousness) is bound to feel a shallowness in life at some point of time or other. Even within one’s life time, the process of ending up in old age deprives one from enjoying artha and kama to any level of reasonable satisfaction and a sense of dejection of not having enjoyed enough lingers in the mind even at the death bed.
This causes subsequent births and the cycle keeps on continuing, because the the fundamental nature of wealth or sensual enjoyments is such that practically no one ever gets a feeling “enough is enough”. This aspect of creation is known as maya. Maya always deludes people to indulge in more and more enjoyment leading only to more and more suffering or dissatisfaction.
At some point of other in life, at some birth or other, man starts wondering whether his hunt for wealth and enjoyment is fundamentally flawed somewhere. He starts seeking more clear answers for the true meaning of birth. It is at this point, a man grows from the clutches of religious faith to spirituality. From the Karma Kanda in Vedas (that gave all the procedures for seeking worldly enjoyments) a seeker elevates himself to Jnana Kanda — Vedanta /Upanishads and he gets the right answers and clarifications now.
He gets mentally prepared to leave behind Artha and Kama and goes behind Moksha as the only meaningful pursuit in life.