Sometime in our evolution
sex began to be determined genetically, switching over from the reptilian trait of deciding sex by the temperature of the egg. This was probably so each sex could specialize in its role starting from conception
. In humans
, males are the result of the sex-determining gene, while females are the result of lacking that gene (keep in mind it's the opposite in birds). That sex-determining gene started to come along with other genes, which resulted in traits benefiting males, for example, large muscles
. In females such genes would simply waste energy that would be better spent on children. When such secondary genes
are at an advantage in one sex, but at a disadvantage in the other, they are called sexually antagonistic genes.
Normally, two paired chromosomes swap genetic material. The problem described above was solved by a mutant gene that suppressed this swapping. Once this happened, the sexually antagonistic genes diverged and specialized further. For example, a gene on the Y-chromosome might take calcium and make it into antlers. On the X-chromosome another version of the gene might take calcium and use it to make milk. On the Y-chromosome genes accumulate that help males, but that can be harmful to females. The opposite happens with the X-chromosome.
Information gleaned from Genome by Matt Ridley, and (badly) interpreted by me.