The evolution of the two genders likely happened after sex had already evolved. All sexual organisms prior to gender specialization would have been hermaphroditic, able to both fertilize and be fertilized. Being fertilized bears a heavy cost, as you have to put considerable energy into growing offspring. A more physically fit organism could fertilize while avoiding being fertilized, over time it might begin to specialize around that as it can still reproduce while avoiding the cost of the offspring. Eventually its ability to be fertilized would vanish completely as it specializes in fertilizing. The evolution of the male. On the flip side, those physically less fit would succumb to fertilization more often than they fertilize, and would eventually lose their ability to fertilize as they specialize around bearing offspring. The evolution of the female. The general trend of the male being more physically fit than the female holds true in most species, with some exceptions. That that trend would be observed at all likely points towards the nature and origin of the two genders. It would also be likely that the same evolutionary process would happen in non earth life systems, at least once sexual reproduction evolves.