Comparisons of closely related microorganisms have shown that individual genomes can be highly diverse in terms of gene content. In this Review, we discuss several studies showing that much of this variation is associated with social and ecological interactions, which have an important role in the population biology of wild populations of bacteria and archaea. These interactions create frequency-dependent selective pressures that can either stabilize gene frequencies at intermediate levels in populations or promote fast gene turnover, which presents as low gene frequencies in genome surveys. Thus, interpretation of gene-content diversity requires the delineation of populations according to cohesive gene flow and ecology, as micro-evolutionary changes arise in response to local selection pressures and population dynamics.