Indian caste (Jati) system is considered as one of the evil system in the modern society. It is the most misrepresented, misinformed, misunderstood, misused and the most maligned aspects of Hinduism. The history and timeline  can be found in various texts. Vast research had been carried out to understand the origin and the impact of the caste system in India which can be found at the website called Hindu wisdom .
Varna system was far more superior system than any other class system existed in the world. According to the Vedic literature, it defines the social order. They were not supposed to compete amongst one another but rather complement each other.  According to Alain Danielou , a Sanskrit scholar, the Varna system actually helped Hindu civilization to survive all invasions for more than four millennia.
Varna system resulted the divisions based on the skill sets and the abilities to perform ones duties effectively and efficiently. It grew organically and later got developed into a well organised system. It is similar to one of the determinant, division of labour (coined by Adam Smith) founding father of the modern economics, for the wealth of any nation . In certain Vedic texts it is described in analogy with the activities of the human body, as shown in the figure below.
I was wondering about where to look for the correlation and obviously I found it in the ancient Vedic science called Astrology. In Vedic Astrology there are four Varnas as described above. The natal chart predicts the dominant characteristic based on the Varna. For e.g as shown in the figure-2 below, the natal chart depicts the subject as born under Kshatriya Varna, which means that he/she will possess the dominant character of the warrior, then other three.
This suggests, and might have been accepted fact, that a Kshatriya child can be born to a father of any other Varna. This Varna system, in the natal chart, might have been used as a tool to predict the trend as well as the characteristics of a child depending on the other aspects of the astrology. This can be considered as an evidence that the Varna is not a virtue of inheritance or a hierarchy. It might have been considered as one of the characteristic of the individual. (Currently the Varna in astrology is used to calculate only the Gunas during the matchmaking for marriage).
Later in time a fifth class was incorporated as Mlechha. According to my assumption this term was used for the people who have committed the heinous crime and ousted from the society. For other crimes the punishment used to be a community service like cleaning streets, institutions etc. It seems, under the influence of the new social order, the Mlechha class got assimilated into the mainstream substituting the criminals, as a result of the new prison system, providing community service. The prison system might have been brought by outsiders, which were built to provide harsh punishments to criminals. In olden times there was no capital punishment and thus the only punishment used seems to be ousting from the community for such heinous crimes. Mlechha community maintained to live outskirts of the village and not allowed to mingle with the local villagers and take part in any processions. I believe this is how the fifth class came into existence.
The caste system of India is also misinterpreted as Varnashrma or VarnaVyavastha. This notion is incorrect. Caste means “Jati or community” and Varna means “skilled class or character”. Jati is also termed as “Gotram” in smritis. Thus Jati is a sub-community, devised their own rules especially for marriages, of the larger class or Varna system. According to some texts, somewhere 1200 A.D Varna system was misinterpreted as Caste system. It got corrupted and was misused to gain political power after Islamic invasion and later became worst during the British rule. Since then it became a stigma on Hindu culture. Acharya David Frawley (Pandit Vamadeva Shastri) , a Vedic scholar, pointed out that “The missionaries in India claims that by eradicating the caste system they (the Christians) are helping people and raising them up socially. Clearly they are using, if not promoting caste-differences as a conversion strategy.”
Disclaimer: The above analysis is entirely my own hypothesis, except as referenced, and has no correlation with any of the research on Hindu class or caste system, if any such exists.
Updated: 30 Nov 2012 – Added division of labour / Update-2-10Apr2014 – Corrected spelling mistakes