Bacteria release and sense small molecules called autoinducers in a process known as quorum sensing. The prevailing interpretation of quorum sensing is that by sensing autoinducer concentrations, bacteria estimate population density to regulate the expression of functions that are only beneficial when carried out by a sufficiently large number of cells. However, a major challenge to this interpretation is that the concentration of autoinducers strongly depends on the environment, often rendering autoinducer-based estimates of cell density unreliable. Here we propose an alternative interpretation of quorum sensing, where bacteria, by releasing and sensing autoinducers, harness social interactions to sense the environment as a collective. Using a computational model we show that this functionality can explain the evolution of quorum sensing and arises from individuals improving their estimation accuracy by pooling many imperfect estimates – analogous to the ‘wisdom of the crowds’ in decision theory. Importantly, our model reconciles the observed dependence of quorum sensing on both population density and the environment and explains why several quorum sensing systems regulate the production of private goods.