First, we agree that race is largely a social term when applied to humans and not the biological classification term used in science.
But what we refer to as "racial differences" emerged over thousands of years and populations were not indifferent to them. In that sense, ancient "racism" was largely practiced as part of natural selection to perpetuate a characteristic that conferred advantage within a specific climate. Outside that environment those same characteristic became disadvantages as they were largely tied to climate.
But once present, they become the basis for tribes to identify themselves and it is only natural for tribes to think of themselves as superior . The term barbarian is derived from the Romans that believed the northern hairy white skinned humans were below them even as their culture and skills were capable of defeating the Romans and ultimately overrunning their empire.
Racial differences and more precisely tribal differences that tend to spread across all tribes in a similar climatic region through mix tribal procreation eventually become seen within the a culture as superior.
Because tribal and racial differences are linked it becomes a bit nuanced to try to separate them. But what does seem to happen is that it is easier for tribes with similar physical appearance to merge. That again suggests some degree of "racial" awareness.
The more interesting thing to consider is now that these largely climatic physical advantages no longer serve any utility will they disappear over time. With technology, we no longer have need of physical differences to adjust to climatic conditions, but we do have need for other biological advantages.
Some biologists are seeing emerging mutations between rural and urban populations among animals of the same species and humans.
https://bmcecolevol.biomedcentral.com/articles/10.1186/s12862-017-1025-9
Will the future "races" be defined by a whole new set of characteristics rather than "skin" color. Probably... again humans are tribal and so they will figure out how to discriminate, even if race is not used.