Why are there males and females? Why are there two sexes instead of three, or twelve, or one?
Let's start with why there is sex at all. When two organisms reproduce sexually, sperm and egg combine, using DNA from both partners to make offspring. Combining DNA has a number of advantages, like correcting defects in each parents' genes, so the offspring are healthier.
Why are there two sexes? This means, if you want to reproduce, you can only mate with 50% of the population, making the perfect mate that much harder to find. If there were only one sex you could reproduce with anyone, and it would be easier to find a mate. You'd think this would be an advantage for survival.
As it turns out, lots of other stuff can happen when two cells combine to reproduce. While the DNA in the cells' nuclei might be happy to join forces, other parts of the cell might not be so pleased with the merger. Specifically, a cell's mitochondria tend to violently resist merging with other mitochondria, and feuding mitochondria can turn the DNA's love feast into a microscopic battlefield.
If there were only one sex, then mitochondria in each reproductive cell would start out on equal footing. They would need to fight it out every time. With a two-sex system, one sex can always unilaterally disarm, surrendering its mitochondria for the sake of easier relations between the sexes. Male sperm cells are smaller than female eggs partly because they surrendered this mitochondrial battle long ago. Female mitochondria always win.