Rich ecosystems harbour thousands of species interacting in tangled networks encompassing predation, mutualism and competition. Such widespread biodiversity is puzzling, because in ecological models it is exceedingly improbable for large communities to stably coexist. One aspect rarely considered in these models, however, is that coexisting species in natural communities are a selected portion of a much larger pool, which has been pruned by population dynamics. Here we compute the distribution of the number of species that can coexist when we start from a pool of species interacting randomly, and show that even in this case we can observe rich, stable communities. Interestingly, our results show that, once stability conditions are met, network structure has very little influence on the level of biodiversity attained. Our results identify the main drivers responsible for widespread coexistence in natural communities, providing a baseline for determining which structural aspects of empirical communities promote or hinder coexistence.