It seems reasonable to think all behavior had a purpose at some point. These actions could've been all early people & societies could've have mustered. Look at stigmatizing illnesses. These people didn't have medicine or sanitation. They didn't understand how illnesses worked.
Perhaps with leprosy, TB or others; stigmatizing was all they knew to do. Think of it as a form of social surgery. Lets cut out the bad part & hope to save the rest. Without the religious zealotry & ideological loathing, isn't that just an extreme quarantining?
In a time of limited resources, the problem was religion, fear & ignorance. They didn't know what illnesses were. Some thought sickness to be a curse or punishment.
Unfortunately only part of society ever grew out of their superstitions. Other's held on to hate & fear. Some people used those emotions to wage war on those found different, lacking or ill. Stigma is nothing new, it moved from being a poor method of social protection to a weapon.
Look at the Crucible. Take the battle against HIV. Take Ebola in Africa. Now look at COVID-19, the illness Trump calls that Chinese virus. Stigmatizing an illness is weaponizing ignorance, fear & hatred. It's been used against the ill, the different & now it's divided a nation.
Stima may be the greatest WMD ever.
Cya...
PS - The man I wrote about yesterday, the Berlin Patient has passed. He died of cancer. Good journeys to you sir. May your next life be full of happiness, joy & prosperity. May people know you.