Dharma is a Hindu concept, from the Sanskrit term for "duty", "law" or "propriety."
In primitive societies religion, law and propriety aren't conceived of as separate things. There is no separation of church and state; no secular vs religious law.
Dharma was a fundamental tenet of Hinduism two thousand years before the Buddha was born.
According to Hindu tradition, the goal of life is to achieve higher states of consciousness, ie: to merge with the Godhead/Universal Consciousness. To this end souls cycle through incarnations (lives) tailored to optimize soul-growth. Dharma is the blueprint for a life. It is the plan for optimizing the spiritual growth that can be achieved in a particular incarnation. Following one's dharma, ie: following the life-plan predestined for a specific incarnation, optimizes spiritual progress.
Dharma, for good or ill, is behind the Hindu concept of "caste." Dharma is traditionally subdivided into four general lifestyles/castes.
Brahmins are born to be clergymen and teachers. Kshatrias are designed for lives in the military or civil-service. Vaishyas optimize their spiritual growth living as tradesmen, or farmers. Shudras are happiest as servants or manual laborers.
There are also, in traditional Indian culture, people whose dharma is unclear, or has become scrambled; people who have no proper caste. These are known as "Dalits," or "outcasts" in English, and are treated as less than human.
The idea that one can be born without a dharma or caste is, of course, absurd, and is rejected by the educated classes. But, though discrimination is outlawed by the Indian Constitution, India seems to have no shortage of redneck bigots perpetuating the injustice.