A mechanistic path to maximize biomass productivity while maintaining diversity