An efficient immune system is essential to the survival of many animals. Sociality increases risk of pathogen transmission, which should select for enhanced immune function. However, two hypotheses instead predict a weakened immune function: relaxed selection caused by social immunity/protection, and reduced efficacy of selection due to inbreeding, reproductive skew and female bias in social species that reduce effective population size and accelerate genetic drift. We assessed the effect of social evolution on immune function in a comparative study of two social spider species and their closely related subsocial sister species (genus
Stegodyphus
). The haemolymph of social species was less efficient in inhibiting bacterial growth of the potentially pathogenic bacteria
Bacillus subtilis
than that of subsocial species. Reduced efficacy of selection in social species was supported by comparative genomic analysis showing substantially elevated non-synonymous substitutions in immune genes in one of the social species. We propose that impaired immune function results from reduced efficacy of selection because the evolution of sociality in spiders is accompanied by demographic processes that elevate genetic drift. Positive feedback between pathogen-induced local extinctions and the resulting elevation of genetic drift may further weaken responses to selection by pathogens, and threaten species persistence.