I just wrote a comment about this in the last few weeks, but idk if it got removed or what.
In Marx's ethnological notes on Lewis Morgan, he reviewed Lewis's work on the ancient Roman gentiles, and their communal lifestyle. So I'm basing what I'm gonna describe on those notes. Keep in mind these social forms existed like 50 BC to 500 ad, and feudal/monarchic society predates that by like 8000 years or something.
There were these egalitarian communes of families with a shard ancestor called the Gens, which were genuinely fraternal social organizations where people shared resources and personal property was redistributed upon death of a member. Over time, distinct sections of the Gen seemed to accumulate different forms of social capital. So you got a group of like doctors, or academics, or leaders, engineers, or manual workers. Not formal divisions mind you, but if you were a member of the Gen you knew which people to go in order to get some function of your society. There was still like a genuine fraternity among the Gens at this point, and the functioning of society for the individual members was formally dependent on egalitarianism.
As this social capital concentrated within a group, the informal divisions hardened into castes, called Gentes. There was still respect and fraternity among the members of the Gens, but Gentes are now starting to act according to their own best interests. The egalitarianism still exists informally, but its more like a principle or value than a need in order for each little Gen society to function. Cultural momentum, not a necessity for survival.
Eventually, the Gentes start jockeying for political power and social position. This process destroys the genuine egalitarianism in every form, and replaces it with social competition and hierarchy. Eventually, one caste, one gent, dominates all others. This creates the "ruling class", which simultaneously creates the other hardened classes. All egalitarian sentiment has been wiped away, both formally and informally, as far as it existed as an essential way that society functions.
In older forms of society, there were many classes that depended on each other for their established place in the hierarchy. Under feudalism the church existed as part of the power structure that maintained monarchic rule. This was extremely stable. But the creation of the bourgeois class created a new middle class that was driven by the relentless search for profit. This relentlessness means that the bourgeois class could not share power. They destroyed the formal power of the church, then the formal power of the monarchy. The capitalist's ability to buy people, to change society, to formalize their own rule, led to their ability to subordinate the old classes and transform them into capitalist institutions. This is the process that leads to the two formal classes of capitalism, worker and capitalist. But I think its worthwhile to treat informal classes, such as peasant and lumpen, middle and small capitalist, nouveau riche and tech oligarchy classes, though there are others, as "real" since they reflect peoples experiences and real accumulation of social capital.
At the same time, there is one relentless search for profit, one global system that determines the character of all others, that determines the central contradiction around which is accumulated the material possibility for a new socialist society