There are ample examples of pathogens adapting towards evasion of immune responses. A well-known example commonly thought to reflect adaptation of hosts to pathogens is the polymorphism of major histocompatibility (MHC) molecules. MHC molecules play a key role in cellular immune responses. The population diversity of MHC molecules is extremely large: for some MHC loci, over one hundred different alleles have been identified. The mechanisms behind the selection for MHC polymorphism have been debated for over three decades. A commonly held view is that MHC polymorphism is due to selection favoring heterozygosity. It has been argued that selection for heterozygosity alone cannot explain the large MHC diversity observed in nature, and that frequency-dependent selection'' is required. We simulation evolution by developing a genetic algorithm in which hosts and pathogens co-evolve. The analysis demonstrates that selection involving rapid evolution of pathogens can account for a much larger MHC diversity than selection for heterozygosity alone can.