Dharma is the principle of righteousness. It is the unifier and sustainer of social life. The code of righteousness is meant to help us regulate our lives in this world -- just as we need a constitution, written or otherwise, that helps us make the framework for the governance of a country or an institution.
Since the constitution of a country is conceived and framed by human intellect it could become out-of-context over the passage of time and therefore, amendments may become necessary, from time to time. On the other hand the rules of righteousness are evolved by the Supreme -- they are valuable and relevant in any context -- and hence they are eternal. There is no room for corruption in its implementation. All are equal before it. Righteousness brings as its consequence happiness, both in this world and in the next. If we protect it, it will protect us.
That which elevates is righteousness. It leads us to the path of perfection and glory and helps us to have direct communion with the Supreme. Righteousness is at the heart of ethics. Striving intently to uphold it is the purushartha or the concept of pursuits of life. And these are dharma or righteous conduct, artha or acquisition of wealth by honest means, kama or desire for physical and mental wellbeing and moksha or liberation of the embodied soul from the vast ocean of acquisitive life.
Scriptures say that dharma and moksha are like the river bed to artha and kama, and so should never be breached. At the end of the Mahabharata war, Bhishma, lying on a bed of arrows, tells Yudhishtira that whatever creates conflict is non-righteousness and whatever puts an end to conflict and brings about unity and harmony is righteousness. Anything that helps to unite all and generates love and universal brotherhood is righteous. Anything that creates disagreement, divide and disharmony is non-righteous. Any righteous act brings good karma.
"Dharmo rakshati rakshita." An incident during the Mahabharata war illustrates this. During the war in the thick of combat Arjuna sees the blurred vision, like a figure exuding a flame-like radiance, in the opposite camp. At the end of the day an intrigued Arjuna asks Vyasa: "What was that blur of light, a figure, I think, I could see in the opposite camp even as I was engaged in combat?" Vyasa asks: "Son, did you notice the figure holding a trident?" Arjuna says" Yes, I could see a trident in the hand." Vyasa says: "He is none other than Maha Rudradeva; He is helping you since the war which you Pandavas are fighting is dharmic" Arjuna asks "If Shiva wants to assist me in the war, why is He in the Kaurava camp? What is He doing there?"
Vyasa tells Arujuna that Maha Rudradeva does not tolerate adharma He is there to deter those who have supported adharma. He is known for destruction; by His mere presence in their camp He is sucking all the vigour of the warriors on that side. Hence Kaurava warriors who were known for their strength now seem weak, sapped of energy. Vyasa tells Arjuna that whatever is done in righteousness, the support to that act comes from all sides. Vyasa says in the Mahabharata: "Do not forsake your code of righteousness out of desire, being overwhelmed by fear or greed or even when threatened with death -- as righteousness is eternal whereas being happy or unhappy is momentary. The embodied soul is eternal and the gross body is perishable."