The notion of dynamic, endogenous diversity and its role in theories of investment and technological innovation is addressed. We develop a formal model of an innovation arising from the combination of two existing modules, with the objective to optimize the net benefits of diversity. The model takes into account increasing returns to scale and the effect of diversification of investments on the probability of emergence of a third option. We obtain analytical solutions describing the dynamic behaviour of the values of the options. Next, diversity is optimized by trading off the benefits of recombinant innovation and returns to scale. We derive conditions for optimal diversity under different regimes of returns to scale. Threshold values of returns to scale and the recombination probability define regions where either specialization or diversity is the best choice. When the investment time horizon is beyond a threshold value, a diversified investment strategy is the best choice. This threshold will be larger for higher returns to scale. This problem is relevant to allocation of scarce funds by governments, research councils, firms and investors.