Product variety and the demographic transition