mp40 submachine gun

It seems like the mp40 submachine gun has the perfect rate of fire, why dont modern rifles and submachine guns use that same rate of fire?

Because they can fire faster?

Probably because Messrs. Kalashnikov, Gal, Stoner,* et al.*, and their colleagues at the arsenals they worked for were seeking to meet specification requirements from their respective militaries that diverged from that definition of “perfect” (and some did not diverge so much – the Uzi is 450 rpm vs. 500 for the MP40). Each procurement proposal would be based on some different study of what works better for the kind of battle you’re expecting to have. (Add to that also in the case of assault rifles that you’re firing an ammunition with characteristics entirely different from the 9mm pistol load)

the mp40 has a slow steady rate of fire a 30 rd clip lasts quite a while, modern guns like the m4 or mp5 the clip wont even last 3 seconds.

Sub machine guns are not designed for extended automatic fire - try to empty a whole magazine at once and you’re more likely to kill yourself. Modern SMGs have such high rates of fire because they’re supposed to be fired in very short bursts of 3-4 rounds at a time, and the faster they shoot, the closer the grouping will be.

It’s odd to praise the MP40 on its rate of fire; the same army wanted 1,200rpm+ out of its machine guns. The MG42 could empty a 50 round drum in 2-2.5 seconds.

They didn’t see the need for individual hand-carried weapons to waste too much ammo; better put one’s resources on a mean machine gun or mortars.