Something related to Hinduism and I must put my 10 cents in (people give just 2 cents). So here is it.
First thing, kindly understand that we have two classifications. None of them is genetic. One is 'varna' or the natural inclination of a person to excel in in a particular job. The second is caste - jati, which so to say, which group does one belong to. The group of story tellers (charan, bhat), entertaining people with physical display, balancing on ropes, etc. (nat), catching snakes (kalbelia), making ornaments (swarnakara or sonar), iron-smith (Lohar), making pottery (Kumhar), trader (vaishya), farmer *bhumihar), etc.
The first social division was brought in by Aryans. It is not indigenous. Why I say this is because the Zoroastrians also have a similar four-fold division, which is mentioned in BhagawadGita (chaturvarnyam maya shrishtam, I created the four varnas), that of brahmins, warriors, traders and agriculturists, and those who work for others.
Now Bhim would not have been very successful as a teacher, and Arjuna would not have been very successful as a office worker. They were more suited for fighting, kshatriyas. But there were others who were obliged to change their profession. The first example is that of Vishwamitra. He was a king's son. But his natural inclination was towards shastras. So he put in effort and became a brahmarshi. Satyakama Jabali was the son of a women who in her younger days worked for others and had sex with many (prostitution), but his inclination also was that of a brahmin, and he went on to become a great sage of Hinduism. Vedavyasa was a mix of Aryan and indigenous persons, Sage Parashara and a fisher woman, Satyavati (Shudra) and compiled or wrote pratically half the books of Hinduism, the Vedas, Brahmasutras, Mahabharata, SrimadBhagawatham. His son through a maid (dasi - shudra), Vidur, too, was one of the wisest people of his time and a sage. There is a verse in RigVeda where a person says that his father is a chariot driver (kshatriya type), he himself is an iron-smith (Vaishya) and his mother is so and so (I do not remember the exact profession of his mother). But it shows that even in one family, there could be people of different varnas.
Caste was an indigenous social division and could depend on many things. For example, regional, I am a Kashmiri, but there are other jatis (castes) of brahmins, there are tamil brahmins, sarayuparin brahmins (brahmins living to the east of River Sarayu), Gauda brahmins (those of Bengal) and the deshastha (those of Konkan and Goa), and Kanyakubja (living near Kannauj), etc. Hundreds of different brahmin castes. Our language, food, and traditions may be different. So, it was thought that the best match could be in one's own caste/jati.
Then the hundreds of professions. People with different origins and tribal associations, Suryavamshis, chandravamshis, agnivamshis, yadavas, jats, gujars (probably the khazars of Kazakhistan), meena, ahirs, bhil, gond, etc. People with different beliefs, Ramanamis, Gorakhpanthis, Kabirpanthis, Smartas, Madhvas, etc.
When the Aryans assimilated into Hinduism, these thousands of castes were put into various varnas resulting in a double categorization which became fixed and according to birth. I am of brahmins varna and in jati, Kashmiri. There are further divisions but I would not confuse you with them. For example those who continued conducting rituals are known as 'gurus' and those who took up jobs with kings are known as 'karkuns' (clerical).
This all made the Hindu society. Of course, times have changed, and caste does not hold the society in the same way as it used to. Intercaste marriages take place. People take up professions which did not happen at one time. A person from a Shudra caste becomes a judge, a vaishya joins military, a brahmin may take up agriculture, and a kshatriya may start a business. There are no bars. But still, you would find an attraction towards studies in a brahmin family, and towards business in a vaishya family. Their relatives may also be engaged in business, and they talk about business in their homes, so naturally a person from a vaishya family may know more about business than a boy from a brahmin or a kshatriya family. They may have contacts which may make it easier to start a business. So, caste also is not without its advantages. An iron-smith or a sthapathy (architect) imparting the tricks of his trade to his son, etc.