F1 is not as popular in Spain because they love motorbikes, you only needed to watch the MotoGP this weekend and see the sellout crowd to know that. Alonso brought some new fans to F1, the ones that grew to like the sport will stay when Alonso retires, the others won't be missed by anyone other than the circuit owners.
As for the racism, I think it was blown out of proportion, they were being racist because they knew it would be extremely offensive and potentially distracting to Hamilton. They disliked Hamilton because of the Spanish media turning him into a hate figure, which is the same reason some people from the UK dislike Alonso, the British press gave him a hard time. It was only a few people anyway, it's not like the racism Spanish football fans are known for which is much more wide spread, although that is decreasing now too.