It was a combination of IFF and defense against bomber gunners. That later worked by giving a stark visual cue to the gunner to focus on, and thus not actually hitting his target because he is not leading it properly.
It also probably helped with safety on the ground by identifying when a prop is spinning.