Reason for different hex screw sizes
Generally, bigger sizes of screw heads allow higher torque to be applied to them. This is also often expressed in lengths of wrenches used for them in workshops: typically a 3 mm L-shaped hex key is shorter than a 4 mm one, which in turn is shorter than 5 and 6 mm ones etc. Multitools are exceptions because of size constraints of tool bodies; it is typical to see a 8 mm hex head on a multitool with inadequately short leverage.

An unnecessarily big screw would also mean more "dead" space is needed in the parts such screw connect. These parts are collars of brake levers, derailleur shifters, grips etc. "hugging" the handlebar's tube. Collars interfere with each other, preventing you from finding the most comfortable position of e.g. brake lever. By the way, this is why top-level brake/shifter combinations basically use a single collar and are connected together (Ispec, MatchMaker etc.)

Bigger torque is needed to counteract bigger force × leverage applied to a specific component. For handlebar components, forces are produced by user's hands/palms and have the same order of magnitude regardless of which component is being "touched". The applied force being fixed, it is the leverage (in centimeters) that should decide achievable range of user-supplied torque and thus required screw-supplied counter-torque.


Lock-on handlebar grips tend to have the smallest screws (1.5 - 2.5 mm) because grips sit very tight to the handlebar. Leverage applied to them is defined by their thickness and is an order of 1 cm.
Shifters typically have relatively large paddles sitting far away from the handlebar's axle, let's say 3 cm away. A 4 mm screw would seem to be adequate to hold them securely.
Brake levers have dimensions and leverage comparable to shifters'. Thus, screws of the same size should suffice for them. However, brakes are more critical to rider's safety, and them rotating around the handlebar is even less desirable. As an additional precaution, they are installed with higher torque and thus bigger screws (5 mm).
Fork lockout control is smaller than both shifters and brake levers, but bigger than grips, so I would say it may have a screw somewhere in-between (2.5 - 3 mm).