The production of egg and sperm cells is necessary for sexual reproduction because it reduces the number of chromosomes so the gametes can combine, giving the organism a complete set of chromosomes.
This process occurs through meiosis, where the number of chromosomes is halved in the gametes (egg and sperm), allowing when they combine during fertilization to restore the diploid number of chromosomes in the offspring.