The heads of insects are orders of magnitude smaller than the heads of even the smallest mammal. Many functional organs and tissues must fit in a limited space. The cuticle covering the compounds eyes doubles as both lens to focus light and part of the structure of the head. Insect eyes are fixed, do not move and have no musculature. These features save some space inside the head.
The head contains muscles responsible for the movement of the antennae and mouthparts. The head has invaginations of the exoskeleton that serve as anchors for those muscles. Food intake must pass through the head. The digestive system in the head consists of a pharynx and esophagus. In sucking insects, the pharynx [food pump] may occupy a substantial area. The esophagus is a tube where food passes out of the head and into the more spacious abdomen where the large digestive organs are located. In some insects, salivary glands are located in the thorax and abdomen with only thin ducts inside the head. These structures all claim space and this limits the volume available for the insect brain.
Cells in all organisms are of similar size. Thus, an insect, with less space for brain cells than mammals will have far fewer brain cells. Their small head size requires insects to use the limited number of brain cells more efficiently.