The emergence and scaling of division of labor in insect societies