@squirbel ”How would evolution know it had the goal of gene pool mixing?”
A fair question, especially with such teleological phrasing. Our body cells undergo asexual reproduction all the time in the form of mitosis. Sexual reproduction at the cellular level only occurs in germ cells—eggs and sperm.
The evolutionary “invention” (i.e., appearance as a heritable mechanism) of sex is still largely a scientific mystery due to lack of evidence, lost in the mists of time.
We know that all prokaryotes (single cells with a circular strand of DNA & lacking a nucleus) divide by mitosis. Sexual reproduction involving meiosis of germ cells only occurs in eukaryotes (mostly multi-cellular organisms whose cells have nuclei and whose DNA is organized as paired chromosomes.) This made possible a distinct X and Y chromosome (or Z and W in some animals) to allow sexual dimorphism—differences between male and female.
By the usual Darwinian mechanism of random variation with natural selection, meiosis somehow arose, allowing offspring to reshuffle the genes from two different parents. From then on it would have been wildly successful, because variation could proceed by sexual recombination, picking up the pace of evolution compared to relying on spontaneous mutations alone as mitosis does.
Note that both plants and animals are eukaryotes and can reproduce sexually.