  Levels of sociality in nature vary widely. Some species are solitary; others
live in family groups; some form complex multi-family societies. Increased
levels of social interaction can allow for the spread of useful innovations and
beneficial information, but can also facilitate the spread of harmful
contagions, such as infectious diseases. It is natural to assume that these
contagion processes shape the evolution of complex social systems, but an
explicit account of the dynamics of sociality under selection pressure imposed
by contagion remains elusive.
  We consider a model for the evolution of sociality strategies in the presence
of both a beneficial and costly contagion. We study the dynamics of this model
at three timescales: using a susceptible-infectious-susceptible (SIS) model to
describe contagion spread for given sociality strategies, a replicator equation
to study the changing fractions of two different levels of sociality, and an
adaptive dynamics approach to study the long-time evolution of the population
level of sociality.
  For a wide range of assumptions about the benefits and costs of infection, we
identify a social dilemma: the evolutionarily-stable sociality strategy (ESS)
is distinct from the collective optimum -- the level of sociality that would be
best for all individuals. In particular, the ESS level of social interaction is
greater (respectively less) than the social optimum when the good contagion
spreads more (respectively less) readily than the bad contagion.
  Our results shed light on how contagion shapes the evolution of social
interaction, but reveals that evolution may not necessarily lead populations to
social structures that are good for any or all.
