Refusing service to a customer because of their race is illegal in my country, but my country is not a banana republic like Thailand. A foreigner is not more likely to have COVID-19 than a Thai. There are way more Thai people entering Thailand from overseas (repatriated) who could be infected with the virus and who could break their quarantine. Did you ever think of that? Given the closure of the border to most foreigners it is actually less likely that a random foreigner would be infected than a random Thai.
By the way, despite my "banana republic" comment, I love Thailand. It is a pity, however, that there are so many ignorant Thais with this kind of banana republic mentality.