That's a very good question and a hot research topic, as a quick web
search for "evolution of sex" will show. The research is particularly
focussed on plants and animals which reproduce both sexually and
asexually, to try to determine not only the mechanisms, but also the
conditions under which one is more advantageous than the other.
Creating new alleles through recombination is thought to be an important
potential advantage of sexual reproduction. One hypothesis I've heard
is that it could help in resistance to parasites. I'm sure there are
other hypotheses, too, but that's about all I know.
Often-recommended books on the topic (though I haven't read them):
Maynard Smith, J., 1978, The Evolution of Sex: Cambridge, Mass.,
Cambridge University Press.
Williams, G. C., 1975, Sex and Evolution: Princeton, Princeton
University Press.
Loren Haarsma