Talent scouts specifically sought out males like Semenya who were erroneously registered as female at birth, knowing that their male physical advantage would give them an edge in women's competitions.
The specific condition he has (5-alpha reductase deficiency) is one that only affects males, conferring upon them internal testicles and a micropenis. But male development, including all the testosterone-driven advantages that distinguish male and female athletic performance, is otherwise normal.
His gold medal in the 2016 Rio Olympics women's 800m, along with silver and bronze being taken by two other males with similar conditions, is the reason why World Athletics (then the IAAF) and, later, the IOC started to move policy away from eligibility by identity documentation to empirical testing of sex advantage.
The policy change discussed in the linked article wouldn't have happened without athletes like Semenya taking advantage of the previous flawed policy, to the detriment of female athletes.