This idea originally came from Sweden, where it is compulsory. Many years ago, the entire country changed from driving on the left to driving on the right. In order to remind everyone that this had happened, the authorities ordered all drivers to drive with their lights on from the date of the change.
Someone noticed after a year or so that the road accident rate had declined significantly, so they made this rule a permanent one and later required all new cars to switch on their headlights automatically when the engine was running.
Research showed that the lower accident rate was due to greater visibility in poor daylight. Northern countries have many hours of twilight, even in the summer, and there are many roads through forests in Scandinavia. Similar conditions occur in Scotland, for example, and my headlights will often come on automatically when I drive up there in the daytime.
Driving conditions in Mediterranean countries are rather different. The light is much stronger and twilight is much shorter, so driving with headlights on in the daytime is rather pointless in Spain, for example.
Another example of EU bureaucrats trying to standardise everything with little overall benefit.