Firstly, there is a broad agreement amongst all schools of Hindu Philosophy (Astika and Nastika schools) that the ultimate purpose of life is Moksha. Only the Charvaka school does not agree with this.The different schools disagree on the way to achieve Moksha.
The most unique concept in the philosophy contained in the Vedas and the Upanishads is the concept of Dharma. Dharma has been defined differently in different texts. Dharma is what guides the individual in various walks and stages of life.
The Astika philosophies (6 in number) believe in the supremacy of Vedas. Read more about them here.
Tumuluri Rammohan's answer to What are the major differences between six schools of Indian philosophy?
In order to understand the purpose of life according to the Hindu Upanishads, the concepts of Rta, and Rna need to be understood.
Rta:
The concept of Rta is another unique concept in Indian Philosophy. What is Rta? Rta is the eternal, cosmic and moral order. Rta represents the basic truth, harmony or system of the universe which no one can violate. In the physical sphere Rta represents the eternal and inviolable law of nature. Rotation of Heavenly stars, alteration of day and nights, flow of rivers, oceans, etc. are regulated by Rta. In the moral sphere, Rta is righteousness. It is the measure of morality. Those who follow the path of Rta, follow the path of Good. They are called Vratani. The path of Rta (Vrata) is consistent with natural cosmic order. In fact, the theory goes as far as saying that even Gods are subject to the laws of Rta.Gods are not above the Rta. One of their basic duties is protection of the Rta. The God Varuna is considered as the upholder of Rta.
Rna:
Rna, translated as debt, is responsibilities and obligations. Man is a social being and his development is possible due to eh efforts of many other fellow beings have, in some or other way, contributed to his progress. Therefore he is under indebted to many members of his society. These debts, three in number, are the Rnas.The three Rnas are
1.
Rishi Rna: Also called as Guru Rna, this represents the debt a being owes to his Guru/Rishi/Teacher. Isaac Newton very famously said that “If I have seen further it is by standing on the shoulders of Giants.” This is the best possible explanation of what Rishi Rna is. One has to live his life in a way that this debt is discharged. How does one do that? The books say by respecting your teacher and his learnings. If we take a modern outlook on this, this debt is discharged by using the knowledge for the purpose for which it exists, not for a contrarian purpose.
2.
Pitru Rna: An individual owes his own existence to his ancestors. Therefore, it becomes responsibility of the individual to sustain the family by giving birth to next generation. By begetting children the individual becomes free from the debt of his ancestors.
3.
Deva Rna: Let us consider that God is someone/something you owe the existence of humanity to. One may consider the five elements of nature to be God. This debt is discharged by paying respect and honouring whatever one considers as God. Sacrifices in Hinduism are one of the ways of achieving this.
Unless these debts are discharged, it is not possible to attain Moksha, the purpose of life.
Purusharthas – The purpose of life
The four purusharthas (Supreme Ends) form one complete whole and are intimately connected with each other. They define the purpose of life. These four Purusharthas are;
Dharma- the pursuit of the right (discharges the Rishi Rna)
Artha- the pursuit of material wealth (provides one with the means for the next one)
Kama- procreation and pursuit of material pleasures (discharges the Pitru Rna)
Moksha – the pursuit of salvation which happens if the above three have been done (discharges the Dev Rna)
A purushartha cannot be pursued by compromising some other Purushartha. As has been stated above, all of them combined form a single whole. Dharma cannot be compromised in the pursuit of any Purushartha.
This is the purpose of life and the way to achieve it.