Primate and human social groups exhibit a fractal structure that has a very limited range of preferred layer sizes, with groups of 5, 15, 50 and (in humans) 150 and 500 predominating. This same fractal distribution is also observed in the distribution of species mean group sizes in primates. Here we demonstrate that this preferential numbering arises because of the critical nature of dynamic self-organization within complex social networks. We calculate the size dependence of the scaling properties of complex social network models and argue that this aggregate behaviour exhibits a form of collective intelligence. Direct calculation establishes that the complexity of social networks as measured by their scaling behaviour is non-monotonic, peaking globally around 150 with a secondary peak at 500 and tertiary peaks centred on 15 and 50, thereby providing a theory-based rationale for the fractal layering of primate and human social groups.