Submachine guns were a staple of combat in the early 20th century. Their light weight and sleek profiles meant that they could be used in many close-quarters situations and their high rate of fire gave them a stopping power to be feared. By the 1980s, however, submachine guns were rarely seen in regular line units.
Now, this isn't to say that the entire class of firearm is faulty or that there isn't a use for them. In fact, many special operations units and police SWAT teams use submachine guns for their ease of control and for the very reason they're discouraged by conventional units: a lesser stopping power compared to automatic rifles.
Created as a mix between a machine pistol and a carbine, the Italian Beretta M1918 and the German MP 18 were game-changers in the trenches of WWI. The American Thompson M1921 (better known as the "Tommy Gun") wasn't ready in time for the war, but served as a basis for every SMG that came after it.
In WWII, the Tommy Gun gave American troops a lot of firepower in a small package. Paratroopers could easily carry them on planes, tankers could keep them handy in case anyone got too close, and infantrymen could maneuver through cities with them with ease. It was often copied but never outdone. It and its sister weapon, the M3/M3A1 "Grease Gun," were mainstays throughout the Korean War and into the early parts of the Vietnam War.
The submachine gun, however, wasn't able to hold up long in the jungles of Vietnam when the M16's durability, range, and 5.56mm ammunition outperformed it in nearly every way. This, however, wasn't its death rattle.
The SMG's maneuverability in close quarters didn't go unnoticed by law enforcement — primarily by SWAT teams. Additionally, SMGs are often chambered in 9mm or .45 ACP, meaning that targets struck by rounds are more often incapacitated than killed. In the hands of law enforcement, an armed assailant could then be taken into custody.
Though modern rifles have made the SMG unpopular in warfare, it still serves a valuable purpose in the right hands.