I'm not convinced it's racism. The same "not real music" argument has been used by people for electronic music. The real reason here is the fact that hip hop and electronic music are fundamentally different from music those people usually grew up with.
My parents (and in extension, me) grew up with 60 and 70 rock music and as a kid I gravitated mostly towards stuff that sounded like an evolution of that. Which is why the first artists I was really into were bands like Oasis, Nirvana, Smashing Pumpkins and Foo Fighters. Hip hop and electronic music was weird to me, they sung/rapped in weird melodies and didn't always use recognizable instruments (to me), preferring to use electronically created samples or parts of other song samples as backing (which my parents called stealing).
Most kids I knew at high school had also grown up with this line of thinking. Rap and electronic music wasn't "real music" because it didn't rely on "real instruments" or "real melodies".
It was only later, when I started to explore more different genres that I grew to really love both electronic and hip hop. I think the music world in general also went through this change, which is why at festivals like Rock Werchter, Lowlands and Pinkpop you see more and more hip hop and electronic artists take the stage, while 10-15 years ago that would've been unheard of.
That said, there are still many people stuck in that "it isn't real music, because it doesn't use real instruments" mindset. My parents have mostly gravitated away from it as well, but still don't understand acts like Lil Uzi Vert and Aphex Twin.