Caste and Varnas are two separate concepts. The peculiarity of the Hindu theory of social organisation is its Varna-asharm organisation. The Varna organisation and Ashram organization are two separate organisations yet the two go together as they refer to the problems of nurture and nature of man.
The Ashram organisation refers to the conduct of an individual in the world (nurture) in different stages of his life and the Varnasharam orgnisation refers to the work that individuals undertake in the society according to the nature and memberships of their respective Varnas.
In the Rigveda (written in about 400 B.C.) only two Varnas are mentioned, the Arya Varna, and the Dassa Varna. There is also description of the division of the society into three orders. Brahmna (Priest), Kshatria (warriors), and Vis (common people).
Image Source: cdn.historydiscussion.net
There is no mention of Sudras. But there reference is given by Aryans by the use of such terms as Ayogye; Chandal and Nishad. With the passage of time, these four orders ultimately become four varnas. According to Srinivas, people of the fourth order were not untouchables and it included the group of peasants, labourers and servants etc.
There was nothing like higher and lower Varnas in the ancient Vedic period. The division of society into four Varnas was based on the need for a division of labour. Brahmans acted as priests, Kshatriyas as rulers, defenders and fighters, Vaishas as traders and peasants and Sudras as servile class or helpers of others. Each Varna worshiped different deities this was because of their different occupational roles.
Later on a distinction came to be made the basis of colour. Varna in Sanskrit also means ‘colour’ and on this basis Arya and Dasa Varnas were contrasted referring to their fair and dark coloure respectively. Later on it became a strong point to differentiate the Brahmins as white, Kshtriyas as red, Vaishas as yellow and with Shudras as blacks.
When the system of inheritance of memberships of the four varnas emerged the stage was set for the births of the castes. The four Varnas became four main castes which then got further sub-divided into several thousand sub-castes.
The Occupational theory believes that functions and functional divisions in society led to the origin of caste system. However, the Classical theory advocates the view that the Varnas, Castes and the caste system originated from the Supreme Being and HE ordained their obligations and privileges.