Genes don't usually disappear from a genome. However, a mutation that affects the transcription of the gene can induce its loss of function. For example, a mutation could introduce an early stop codon -- a bit of DNA that interrupts transcription. The result is a truncated RNA that can't make a functional protein. Such a mutation inactivates the gene because it can no longer produce the protein it was coding. Gene inactivation is a mechanism that has shaped evolution by allowing new genes to replace the old ones (which remain in the genome, only they become part of the non-coding DNA).
In humans, an example is given by CMAH, which is a gene in most mammals, but has turned into a pseudogene (which means it lost its functionality) in humans due to a mutation that's estimated to have appeared approximately three million years ago. (On a side note, these historical estimates are made through algorithms that compute the evolutionary phylogenetic tree of a genetic sample of sequences, something I'll try and explain in more detail in a future post.) CMAH codes an enzyme called Neu5Gc, but it so happens that this enzyme is an antigen in humans: when detected, our immune system attacks it and destroys it.
Researchers from UCSD have investigated the evolutionary process behind the loss of functionality in CMAH  and found that it was driven by the female immune system.
The Neu5Gc enzyme covers the surface of the cell and it's often used by pathogens as a docking means for cell targeting. Therefore, it's been hypothesized that individuals without this enzyme experienced a selective advantage because of immunity against such pathogens. However, pathogens change quite rapidly and find other ways to attack the host, so that alone is not a feasible explanation. The UCSD researchers used a transgenic mouse model with the added human mutation in CMAH to test the hypothesis that the female immune system can attack either sperm or fetal tissue expressing the Neu5Gc enzyme. Indeed, they found that female mice with the anti-Neu5Gc antibodies showed reduced fertility when mating with Neu5Gc-positive males. Furthermore, they showed that human serum can attack chimpanzee sperm, which is rich in Neu5Gc levels.
Ghaderi et al. used these results to model the fixation of the mutated CMAH human allele and concluded that the female immune system, by attacking the Neu5Gc-positive sperm, significantly reduced fertility with Neu5Gc-positive mates. This resulted in an enhanced fertility between negative CMAH pairs and quickly drove the CMAH mutation to fixation (thus causing the gene inactivation in the whole population).
The question is: if Neu5Gc was originally present in the organism, how did the first humans develop an immunity against it? How events exactly unfolded (and when) is still a puzzle, but Ghaderi et al. suppose that first there had to be a loss of both wild-type alleles in a minority of the population. From a population genetic point of view, this is likely to happen when a group of individuals is isolated from the rest, either through migration or because of a geographical or cultural split in the population. New mutations arise and, the smaller the population size, the more likely they are to "survive" selective pressure. The individuals with the silenced CMAH gene later developed an immune response against Neu5Gc to which they were exposed possibly through a diet reach in red meat (which is rich in Neu5Gc). The loss of functionality in the gene CMAH, combined with the new immune response, triggered the mechanism described by Ghaderi et al. These findings are compatible with the fact no Neu5Gc was found on Neanderthal bones but only its equivalent, Neu5Ac.
 Ghaderi, D., Springer, S., Ma, F., Cohen, M., Secrest, P., Taylor, R., Varki, A., & Gagneux, P. (2011). Sexual selection by female immunity against paternal antigens can fix loss of function alleles Proceedings of the National Academy of Sciences, 108 (43), 17743-17748 DOI: 10.1073/pnas.1102302108