Well wearing a hijab isn't only about covering the hair, by wearing a hijab a woman is also forced to cover her body (I mean have u ever seen someone cover their head and not their body?). That way she's dressed in a way that least attracts attention, especially unwanted male attention. And so she's less likely to be approached or harrassed.

That's only my personal reasoning.