Good guys wear white

Need origin/history of 'GOOD GUYS WEAR WHITE'

Hollywood Western mode: good guys wear white hats - all the "good guys" wear white hats and all the "bad guys" wear black ones

Anymore that has rather faded actually a white western hat is 50% cooler than the sun attracting black one.

I am rural Colorado