Part of the problem is plague, as in infectious disease. This factor drove us to evolve into preferring small separate tribes over big ones. Once your brain can't keep track of all the neighborhood, it starts wanting to categorize folks into groups, and separate us from them.
In fact, all of civilization is in defiance of some base instincts, in which we presume people of different color, who speak different languages, who have different cultures or worship different gods, all are indicators that they are dangerous.
In the time before livestock (from which we caught bunches of infectious diseases, died a lot and developed immunities), a mutant influenza was deadly and strangers were dangerous. And this is seen as empires explored new worlds, exposed indigenous peoples to their array of diseases and wiped them out.
As a note, since germ theory, we replaced segregation with robust communal disease control. And even then, movements rise up to distrust vaccines, masking, social distancing and even washing hands. The same shit that happened during the COVID-19 epidemic also happened during the Spanish Flu epidemic.
So we never really had time to evolve to meet the expanding size of civilization, and had to fake it. In small groups there's just not much political power to consolidate, but by the time we're making villages and cities, we start seeing classes beyond tribesman and chieftain.
What is curious is that we've proven that political power and advantage saps away empathy and respect for your fellow human, so any time there is a significant power differential, the working class feels expendable according to the working class. (They aren't, and some elites will preserve awareness of this, but it's difficult to be a billionaire and still respect wits and education when vibes are so easy.)
It doesn't help that the ownership class conspires among its own to preserve power within its group (all the while, individually contriving to seize the power of their peer for themselves -- avarice is brutal), so anytime we see in history an attempt to create a socialist democracy, capitalist interests act to sabotage the effort, including killing the organizers and sending in military force to seize power and install a puppet junta.
So yes, we really are bad at this, and are not merely going to drive ourselves to near extinction, but are also killing off most of the species across earth.