A critical but poorly understood pattern in macroecology is the often unimodal species - body size distribution ( also known as body size - diversity relationship) in a local community ( embedded in a much larger regional species pool). Purely neutral community models that assume functional equivalence among species are incapable of explaining this pattern because body size is the key determinant of functional differences between species. Several niche-based explanations have been offered, but none of them is completely satisfactory. Here we develop a simple model that unites a neutral community model with niche-based theory to explain the relationship. In the model, species of similar size are assumed to belong to the same size guild. Within a size guild, all individuals are equivalent in their competition for resources, sensu Hubbell's neutral community model; they have the same speciation rate and dispersal capacities. Between size guilds, however, the total number of individuals, the speciation rate, and the dispersal capacities differ, but using known allometric scaling laws for these properties, we can describe the differences between size guilds. Our model predicts that species richness reaches an optimum at an intermediate body size, in agreement with observations. The optimum at intermediate body size is basically the result of a trade-off between, on the one hand, allometric scaling laws for the number of individuals and the speciation rate that decrease with body size and, on the other hand, the scaling law for active dispersal that increases with body size.