There are lots of different conditions that fall under the umbrella of intersex. In humans, the phenotypic sex is usually determined by a pair of sex chromosomes: females being the homogametic (XX) sex and males being the heterogametic (XY) sex. Usually, genetic sex determines gonadal sex; however, this is not always the case. If anything in the sex-determining cascade is faulty, it can result in disjunction between genetic and phenotypic sex, leading to a complete spectrum of phenotypic genders.
Male and female genitalia develop differently because of a hormone called 5a-dihydrotestosterone (DHT), which is essentially a stronger, more powerful version of testosterone. DHT is present around the local tissue of developing genitals in males but not in females. So, if someone with XY chromosomes were to have a DHT deficiency, they would develop female genitals. This condition is known as guevedoces.
However, the difficult psychosocial element for people with guevedoces is that they will have female genitals when born, but suddenly develop male genitalia as testosterone levels rise at puberty. Interestingly, most people with guevedoces exhibit socially conventional heterosexual male behaviour and sexual orientation.
In essence, any one of us could have been born with external genitalia that does not match our chromosomes, but that would not change us as people.