According to legend – from the body parts of the god Brahma.
The main point is this: after you die, your soul will be transferred to another living being when it is born. And if you fulfill your dharma, your next life will be better and you will be born a member of a higher caste. But the point of all these rebirths is not to take birth as a brahmana. The ultimate goal is to get rid of all this carousel. This whole karmic system is an extremely interesting and original way to order society from top to bottom. Everyone has a role to play, and since this role is based on religion, society remains in balance.
Remember: The process of learning a person lasts a lifetime. The value of the same knowledge for different people may be different, it is determined by their individual characteristics and needs. Therefore, knowledge is always needed at any age and position.