I remember when I was at primary school (back in my day!), in our class there were two 'top' students. I was (not trying to boast but this is a fact) one of them. We both got 100% in every spelling and maths test, and we did so exclusively among our peers.
The problem was that the other top student was a girl. This meant that she would study ahead through all the work books on her own with minimal prodding from the teacher. Meanwhile I was off chatting to my mates at the bin pretending to sharpen pencils half the day. When not at the bin we would enjoy pelting each other with crayons, talking about cartoons and what not.
After a while I came to the conclusion something was wrong with me. I wondered why couldn't I be teacher's pet like the clever girl, doing all the workbooks by myself etc. I got the test results but I didn't have the work ethic. I liked to mess around at school.
Point is bright girls are conscientious and hard working at primary school. Bright boys are annoying. Annoying the teacher and being a smart ass is a favourite way for the bright boy to get attention.
Boys need a lot more structure and discipline to work hard in primary school than girls do. The 'soft' education system and fashionable ideas of 'work at your own pace' suite girls but are catastrophic for boys, hence countries that implement these ideas have a bigger educational gender gap.
I would suggest that moreover, just having girls around boys in the classroom is demoralising for boys, who cannot compete with girls in terms of things like conscientiousness, keeping still and quiet, pleasing the teacher. This isn't good for the confidence of a bright boy and I say this as someone who experienced it.
The girl in the class went on to be a somewhat well-known scientist at CERN. I'm doing well enough and finally have come to understand why I was not and could never have won the teacher's favour in such a classroom. It's not fair on boys and it is better to educate them separately.