Bacterial cells, like many other organisms, face a tradeoff between longevity and fecundity. Planktonic cells are fast growing and fragile, while biofilm cells are often slower growing but stress resistant. Here we ask: why do bacterial lineages invest simultaneously in both fast and slow growing types? We develop a population dynamical model of lineage expansion across a patchy environment, and find that mixed investment is favored across a broad range of environmental conditions, even when transmission is entirely via biofilm cells. This mixed strategy is favored because of a division of labor, where exponentially dividing planktonic cells can act as an engine for the production of future biofilm cells, which grow more slowly. We use experimental evolution to test our predictions, and show that phenotypic heterogeneity is persistent even under selection for purely planktonic or purely biofilm transmission. Furthermore, simulations suggest that maintenance of a biofilm subpopulation serves as a cost-effective hedge against environmental uncertainty, which is also consistent with our experimental findings.