I've been teacher of 3 to 7 year olds for the past 25 years so I can answer your first part of the question.
Little girls of elementary school age (I am meaning 4 to 7) mature verbally and emotionally much quicker than boys. Girls tend to favour activities that involve reading, writing and speaking at that age, whereas boys like activities that involve construction, physical activities and moving about.
Because school is structured such that children focus on learning how to read and write etc then it naturally falls that more little girls do well in tests at that age, than do boys.
Schools do also test children on physical abilities but the emphasis does tend to be more on the academic achievement of the child. Also, because kids of that age are not accomplished writers, tests in areas such as science, history, geography etc tend to be verbal, which of course means that the girls, with their more mature verbal abilities, give better answers.
Schools do factor this into the scores children recieve for tests at that age, but sadly you cannot fight against nature. Little boys are just not as ready for reading, writing etc as little girls are when they are in elementary school.
Boys quickly catch up in the years 7 to 11 and often then overtake the accomplishments of the girls at that age. However, it is true that if a child is made to repeat grades with younger children in his early years, then this sets up something of a 'self - fulfilling - phrophecy'. The boy sees he is left behind his peers, thinks he must be stupid, so stops trying.
In the UK where I am no child ever repeats a grade for this very reason. The classes are structured so that the teacher provides different work for each ability group of children. This might be up to 6 or 7 different work provided for one class for one half an hour lesson.
So schools do try to address the problem as best they can. But it is also up to parents to be working even more closely with their little boy to ensure he does not fall behind, given the inborn disadvantages his gender faces at that age.
As for high school kids, I don't know enough about them to answer.
More boys are given ritalin in schools because more boys are identified with ADD or similar disorders and diagnosed by their doctor. Few kids are actually given ritalin IN school, because it is such a serious drug and few Headteachers would be willing to take responsibility for giving a child a drug such as that. Normally ritalin is given to the child at home. If he/she needs it in school time then a parent will be required to come into school to administer the drug themselves.
Whether more boys SHOULD be taking this drug is another point entirely. Some kids it helps but IMO far too many children are just diagnosed with disorders and prescribed heavy duty drugs on the flimsiest of evidence. Too many parents have forgotten what it is to be a boy - to want to move and shout and play fight and NOT just to want to sit quietly in front of the TV. So they think their boy has something wrong with him when really he is just been a boy. Far too many children like these are then drugged out of acting normally like a normal 3 - 7 year old male does act!
Parents need to remember that the needs and behaviours of little boys and little girls are very different. Little boys are not just little girls with a penis!
Good question BTW!! :)
EDIT - Oh just to add, there is a biological reason why boys aren't so ready for 'sitting down and learning' tasks at the age of 4 - 7. They experience a massive surge of testosterone into their body at that age which makes them obsessively 'male', only valuing typically male activities. Presumably in cave man days etc, this was so that little boys, having been weaned off their mummy, would then focus almost completely on their father and male role models and quickly learn the survival skills they needed.
But it is a disadvantage for a boy in a modern society where that is no longer neccessary.
As the testosterone levels out (7 to puberty) the boy becomes more into the more 'female' activities of reading, writing, sitting down at a computer etc.
Again though, at puberty, testosterone kicks in again and a boy gets interested in sex etc, which takes his mind away from studies, which may be a factor in why boys fail more in high school. And also why both boys and girls do academically better in single sex schools at the ages of 11 to 18.