Genome expansion in early eukaryotes drove the transition from lateral gene transfer to meiotic sex