One last thing to note about Lovecraft's racism was that it was a really fucking weird, obsessive kind of racism that was born out of his rough, incredibly isolated, and sheltered upbringing, probable genuine mental illness, and like others have stated, a genuine fear of the unknown.
Lovecraft grew up in a family full of loonies (his father was committed to an asylum, and later died of syphilis, and his mother would later go onto to be committed to and die in the exact same one when he was an adult for reasons that are still unclear) who still considered themselves proper, well-bred, white, English elites, and that anyone who wasn't that was at best a second-class citizen, and at worst, a subhuman degenerate that was to be avoided at all costs.
He was already kind of cuckoo from the moment he was born, and would've probably always been a bit of weirdo, but had he been raised in a more stable environment that held less racist views, and actual let him socialize with the outside world, he probably wouldn't have turned out nearly racist, and delusional as he eventually did.
A fact that was proven true as when he was forced to actually do so, his vehement, and frankly, somewhat schizo beliefs about race, and ethnicity, calmed down incredibly.