In ecology, the 'aggregation model of coexistence' provides a powerful concept to explain the unexpectedly high species richness of insects on ephemeral resources like dung pats, fruits, etc. It suggests that females aggregate their eggs across resource patches, which leads to an increased intraspecific competition within occupied patches and a relatively large number of patches that remain unoccupied. This provides competitor-free patches for heterospecifics, facilitating species coexistence. At first glance, deliberately causing competition among the females' own offspring and leaving resources to heterospecific competitors seems altruistic and incompatible with individual fitness maximization, raising the question of how natural selection operates in favour of egg aggregation on ephemeral resource patches. Allee effects that lead to fitness maxima at intermediate egg densities have been suggested, but not yet detected. Using drosophilid flies on decaying fruits as a study system, we demonstrate a humpshaped relationship between egg density and individual survival probability, with maximum survivorship at intermediate densities. This pattern clearly selects for egg aggregation and resolves the possible conflict between the ecological concept of species coexistence on ephemeral resources and evolutionary theory.