Why was the Varna system (hierarchical social order) created? Is a person's Varna (caste) determined from birth? Does Sanatan Dharma describe caste discrimination?


Caste system was created to ensure the smooth functioning of creation.
Shrimad Bhagwat Mahapuran (11.17.10)
confirms that at the beginning of this Kalpa, all human beings had only one caste called 'Hans'. At that time, all people were satisfied from birth.
With time, the Vedas and the Karma form division were divided into four castes ie Brahmins, Kshatriyas, Vaishyas, and Shudras. Brahmins are considered to be the mouth of God, Kshatriyas are deemed to be the arms of God, Vaishyas are considered to be the thighs and Shudras are considered to be the feet of God.
Yajna(A vedic ritual), Yajna(officiating a yajna), studying, teaching, giving donations, and taking donations are the duties of Brahmins.
Valour, brilliance, patience, cleverness not running away in the war, giving donations, and. the ability to rule are the duties of Kshatriyas.
Farming, protecting cows, and doing business are the duties of Vaishyas.
Serving all other Varnas are the duties of Shudras.
Bhagavad Gita (18.41)
God says that the Varna (caste) of a man is determined not by birth but by his deeds.
This makes it clear that there is no caste distinction in Sanatan Dharma. Over time, caste distinction was given priority to degrade Sanatan Dharma.