Complete androgen insensitivity syndrome
xkcd's Randall Munroe writes that "The role of gender in society is the most complicated thing I’ve ever spent a lot of time learning about, and I’ve spent a lot of time learning about quantum mechanics." I'm not sure if I'd rank gender as the most complicated thing I've spent a significant length of time thinking about, but it's certainly in the top five and probably does beat out quantum mechanics. Generally the rules taught in high school biology like "XY means male, XX means female" are true in most cases, but sex and gender aren't clear cut, and there are always exceptions. When the cells' androgen receptors are rendered inoperative by their genetic programming, the body simply doesn't develop according to the script.
What's interesting (to me, someone who hasn't taken a biology class since I augured in on the IB biology exam in high school) is that feminine development proceeds so smoothly once masculine development is roadblocked. Most women with CAIS don't find out about it until their teens, when an absence of menarche is the first noteworthy symptom to surface. Women with CAIS are always infertile, but other than that are nearly indistinguishable from women with a completely different genetic makeup. While the blueprint that governs human development is fixed at conception, clearly there's significant room for interpretation as life rolls on.
Also, there's at least one Reddit AMA with someone with CAIS. I found it interesting, and you might, too.