From what I heard it's so that if two trains are approaching one another at the same time, it's so the headlights don't dazzle the opposing driver. More of a potential issue now with the LEDs on the 777s.
@@EdwardMason9000 : People always underestimate the brightness of LED lightbulbs, & it's leading to a world that is intolerably bright. The shower room in my flat has 4 lightbulbs & if I get up to go to the loo in the middle of the night it hurts my eyes.