Sex is quite an embarrassing subject for biologists, because we don't know why it evolved, and more importantly, we don't know why it is maintained. Sexual reproduction is a massive cost to the organism because they not only need to find mates, but half of their offspring (males) do not directly contribute to growing the population. There are theories on why sex is maintained based on who you talk to. For example, parasitologists will point you to immunological models showing that more genetically diverse populations have greater resistance to, and smaller loads of parasites. As for the mushrooms, they're known as mating types, rather than sexes.