Most people are genetically either XX or XY, but some aren't. (https://en.wikipedia.org/wiki/Klinefelter_syndrome, https://en.wikipedia.org/wiki/XYY_syndrome)
Most people are born with either male or female genitalia, but some aren't. (https://en.wikipedia.org/wiki/True_hermaphroditism)
Most people's genitalia corresponds to their genetic gender, but for some it doesn't. (https://en.wikipedia.org/wiki/Complete_androgen_insensitivit...)
Most people's psychological gender corresponds to their genitalia and their genetics, but for some it doesn't. (The entirety of the trans* issue)
The only reasonable way forward is to make legal gender optional and changeable. The idea that you can, or worse, should, classify every human into one of two options is wrong. It's a bizarre conservative, Victorian idea that nature should somehow always be neatly categorized, and when it can't be, those that don't fit in are somehow "wrong".
No, the reality is that nature is messy and anything but neatly categorizable, therefore our systems should be flexible enough to handle that.