Amina Inloes, Amina Inloes is originally from the US and has a PhD in Islamic Studies from the University of Exeter on Shi'a hadith. She is the program leader for the MA Islamic Studies program at the... Answered 2 months ago

The main underlying purpose behind hijab seems to be discouraging harassment or misconduct from men and encouraging modest interactions. 

When it comes to protecting girls from sexual harassment or indecent conduct from men, I certainly don't think that a girl has to be mature enough to understand things that her parents tell her to do. For instance, parents might tell a child not to wear certain things in public, not to go certain places alone, not to talk to certain people, not to get into a car with a stranger, not to talk to strangers online, etc. 

The parents say these things because the child isn't usually old enough to understand them.

Of course boys should be protected too, but usually there is an extra concern about girls. 

Obviously the hijab does not wholly prevent harassment or misconduct, and it is wrong to say that it does, but since discouraging harassment and encouraging modest interactions seems to be the underlying purpose behind it, this is the angle I am responding from.

There are other things surrounding the hijab such as presenting one's identity as a Muslim. Most children who are nine years old are able to understand that and verbalize it to others (e.g. "I wear hijab because I am Muslim") if they have been raised in a religious family or environment. 

Of course, I understand that hijab can be stressful in a minority situation and there may be things that the child is not yet ready to handle, such as Islamophobia or bullying. This might be a different situation. However, these are more situation-related, not related to the main idea of hijab.