The origins of the caste system can be found in the holy texts of Hinduism, known as the vedas. According to the vedas, every citizen has a different varna, or caste. Originally, someone's varna would have been based upon actions in life, but the varnas eventually became hereditary, solidifying a rigid stratified system which endured for centuries. The caste system may have provided everyone a place in Indian society, but it did not allow for social mobility and flexibility, and many 20th century Indians considered it to be very discriminatory.
The word "Kshatriya" is derived from the words for "power" and "ruler." Members of this caste have traditionally ruled over communities and Indian society. Ideally, a Kshatriya ruler would have been just and merciful, governing the community with inherent ruling qualities granted by his varna. It was also common for children born into the Kshatriya caste to be extensively educated in statecraft and history, to ensure that they would make sound rulers.
Before the caste system was fully codified, the Kshatriyas were actually the highest caste. Allegedly, the Brahmins replaced them on the orders of Vishnu, who was punishing the Kshatriyas for their tyrannical rule. This may reflect a classic conflict between priests and soldiers, who have struggled for control of their societies for centuries. In modern India, other castes may hold office and join the military, as part of a series of general reforms which were meant to abolish discriminatory aspects of the caste system.