This only works if there are multiple racial groups within a colonial society.
If there are such groups, the colonial power can use racial fear or hatred to make sure that the colonies do not rebel against the "mother country." For example, in Spain's empire, there were "criollos" who were of Spanish descent but born in the Americas. They were unhappy with being treated as second-class citizens by the "peninsulares" who were born in Spain. But the peninsulares could use the criollos' racism to separate the criollos from the Indian and African people in the colonies. This sort of "divide and rule" strategy used racism to more effectively control the colonies.
One way racism is effective in colonial ruling because it tears down the spirit and moral of the person being victimized. this in turn make a more submissive and obedient individual.