Or you need to identify those who aren't behaving properly (sickness or other resource intense disability) and should be outcast from the group (something we don't need to do today, but the right wing narrative insists that need to do)
It would be a evolutionary benefit to fear / avoid any person that is behaving strangely in certain distinct ways. Could be a dangerous transmittable disease, i.e. rabies etc.
The humanoids we evolved from were at one point, not the only humanoids around. We coexisted with other, different species (neanderthals being an example). Homosapien is just the one that survived.
Or the biological need to be afraid of ourselves because if I saw a human standing in my backyard in the shadows I would be as scared as if it were an alien, humans aren't a joke when they want to kill or maim and humans love to kill or maim if they need something you have
Our instincts draw from pretty far back in our biological origins as well. The notion of mimiclike predators is pretty damned ancient and likely a factor for very earliest common ancestry.
"But in general, take my advice, when you meet anything that's going to be Human and isn't yet, or used to be Human once and isn't now, or ought to be Human and isn't, you keep your eyes on it and feel for your hatchet."
Back 4 million years the whole world really was a planet of the apes. So in some ways recognising something that wasn't your species, but looked like it might have avoided conflict, loss of territory, loss of food..
Illness, death, and antisocial behavior. All of these were threats we evolved to handle, people who are "a little bit off" in one way or another, who might endanger the group or individual. This, and that our pattern seeking brains don't like it when something doesn't easily fit within an existing schema, even more so if it lies just outside of our existing preconceptions.
Obviously, I can't say that these definitely are the reasons why we experience the uncanny valley, but I think it's probably a better explanation than... Skin walkers? Or whatever else the meme would be implying.
Still, it's a cool premise for a horror story at least.
I call this feeling "The Holy Spirit" and no I'm not religious, hear me out.
So there's "The Father" which is you, in charge of everything.
Then there's "The Son" which is your Jesus, the bit of you that does shit mostly perfectly without any input from you. The scary example of this is when you drive to work and can't remember the drive at all. Jesus Take the wheel. Teach your Jesus right and you can trust he'll do things fine.
Then The Holy Spirit, which is that part of you that sees everything, before the filters are applied, and let's you know something is off. There's no obvious reason for it, but there's something off about this guy and we need to get away from him as soon as possible and never interact with them again.
The Jesus part is the important bit for most of us. Learning to play the guitar? Teach your Jesus. When you've practiced enough you can just trust that Jesus will hit the notes while you concentrate on singing along.
When I learned to Juggle I just taught my Jesus how to throw properly so it lands in the other hand.
At work I teach my Jesus how to do the manual labour, do the checks I need to do, and I can concentrate on ripping on my work colleagues.