The vinegar worm (officially known as Caenorhabditis elegans) is about as simple as an animal can be. When this soil-dwelling nematode reaches its adult size, it measures a millimeter from its blind head to its tapered tail. It contains only a thousand cells in its entire body. Your body, by contrast, is made of 36 trillion cells. Yet the vinegar worm divides up its few cells into the various parts you can find in other animals like us, from muscles to a nervous system to a gut to sex organs.

In the early 1960s, a scientist named Sydney Brenner fell in love with the vinegar worm’s simplicity. He had decided to embark on a major study of humans and other animals. He wanted to know how our complex bodies develop from a single cell. He was also curious as to how neurons wired into nervous systems that could perceive the outside world and produce quick responses to keep animals alive. Scientists had studied these two questions for decades, but they still knew next to nothing about the molecules involved. When Brenner became acquainted with the vinegar worm in the scientific literature, he realized it could help scientists find some answers.

Its simplicity was what made it so enticing. Under a microscope, scientists could make out every single cell in the worm’s transparent body. It would breed contentedly in a lab, requiring nothing but bacteria to feed on. Scientists could search for mutant worms that behaved in strange ways, and study them to gain clues to how their mutations to certain genes steered them awry.

Brenner’s instinct proved correct. In 2002, he shared the Nobel Prize with John Sulston and Robert Horvitz for their research on the vinegar worm. Other scientists have done pioneering work on the animal as well, with over 22,000 papers published on it over the past five decades. Today, they show no signs of slowing down.

But something fascinating unfolded along the way. The more scientists examined the supposedly simple vinegar worm, the more complexity they uncovered. And some of the most fascinating complexity about the vinegar worm involves its sex life.

By comparison, our own sex life is pretty dull. In humans and many other animal species, individuals are typically either males or females. The males produce the sperm, and the females produce the eggs. In C. elegans, individuals can either be males or hermaphrodites.

The biology of the male worms is straightforward enough: they have sperm, which they can insert into a mate. But the biology of the hermaphrodites is unquestionably strange. They start out life essentially as males, producing sperm that they store in a special chamber deep inside their body. Later in life, their gonads undergo a radical transformation: now they only make eggs.

The hermaphrodite never develops an organ for delivering sperm into other worms. And so it can only use its sperm to fertilize its own eggs. When an egg is ready to develop, it swims past the sperm chamber, picks up a sperm, and then continues on to the worm’s uterus, where it can develop into a larva. This self-fertilization is called selfing.

For a male worm to become a father, he has to interrupt the selfing going on inside a hermaphrodite. After mating, the male’s sperm swim to the chamber, where they dump out the hermaphrodite’s own sperm and swim inside to take their place. When an egg travels past the chamber, it picks up the male’s sperm for fertilization.

Another peculiar feature of the sex life of vinegar worms is the balance of the sexes. In many species—like our own—the population is split pretty much down the middle, half male and half female. The balance is more complicated for the supposedly simple vinegar worm. Many scientists still raise the strain that Sydney Brenner selected in the early 1960s. Those worms will typically produce one new male for every thousand females. The frequency of males can by higher in wild populations, though. In some places, a third of the worms turn out to be male.

Scientists are left with some puzzling questions. Why do males vary from one population to the next? Why are there even males at all?

On paper, at least, abandoning males would seem like the superior evolutionary strategy. If a hermaphrodite produces only hermaphrodites, all of its offspring can start reproducing as soon as they become mature. The males can only reproduce if they find a willing hermaphrodite. And even then, their offspring will only inherit half of their genetic material. By this reasoning, you would expect that the genes for making males should have disappeared from the C. elegans gene pool long ago.

To find out why males stick around, Henrique Teotonio, a biologist at Ecole Normale Superieure in France, and his colleagues have run experiments on vinegar worms. They mix males and hermaphrodites together and rear them under challenging conditions, holding back on their regular supply of bacteria to eat. They then let the worms reproduce for 100 generations, watching for any changes along the way.

Over the course of the experiment, Teotonio observed, the worms produced more males. Somehow, natural selection was favoring a more male-heavy ratio. And at the end of the experiment, the scientists compared how well worms produced from outcrossing did against worms produced by selfing. The outcrossed worms fared better.

These experiments hint that outcrossing has some advantages over selfing. When a male fertilizes a hermaphrodite, their offspring inherit a mixture of genes. Across a whole population of worms, this has the effect of shuffling different decks of genetic cards together, producing new combinations of different variants of genes. Some of these new combinations may prove to make worms better able to meet the challenges posed by their environment.

Selfing, on the other hand, can’t shuffle the decks much, because a worm is simply combining its own sperm and egg. Sometimes a mutation will arise that will make a worm better able to survive, but this is a slow way to produce genetic variation. As a result, selfing worms may be less able to cope with life’s challenges.

Still, the advantage of males has its own limits. Other experiments Teotonio has run suggest that hermaphrodites hold onto their own sperm as an insurance policy. If they had to depend entirely on male worms for sperm, they would run the risk of never finding a mate in their short lifetime and never producing offspring.

These insights are shedding light on the long-term evolution of C. elegans. The most closely related species of worms have males and females, indicating that the ancestors of today’s C. elegans started out that way, too. But then mutant females arose that could produce their own sperm. They became more common, thanks to the advantages of selfing, although a little outcrossing still offers some evolutionary benefits.

In worms with two sexes, the males attract the females by producing courtship chemicals. In C. elegans, the males still release those same chemicals. But hermaphrodites no longer respond as their female ancestors did. They immediately try to escape the attentions of the male worm. By minimizing sex, the vinegar worm may get the most benefit from sex while paying the fewest costs.

If there is a simple lesson about sex that the vinegar worm can teach us, it’s that sex is never simple. Evolution transforms it into an ever-shifting rainbow of forms. And in the simplest animal imaginable, sex can be wonderfully difficult to decipher.