Looking through old photos of say WWI through Vietnam, it seems that helmets were alway a requirement yet body armor wasn’t until around the 21st century. Besides weight and materials, why were helmets seen as necessary at all?
Body armor was extremely inefficient until the 21st century. There are some instances of soldiers using body armor in World War II such as the Soviet SN-42 armor, but it was often discarded by soldiers who knew that being fast was more important that being armored. The SN-42 could stop sub machine gun rounds reliably, but it would not deflect rifle rounds that achieved a 90 degree impact against the soldier wearing them. Similarly in Vietnam, American soldiers were issued flak vests to stop fragmentation attacks from wounding them, but these were often not worn to begin with or discarded because they added a lot of weight and offered no protection against common forms of attack.
The helmet similarly been traditionally ineffective against small arms fire, but has always been worn to stop shrapnel from immediately incapacitating a soldier. Helmets in the twentieth century could deflect a bullet if the bullet was small enough or if it was impacting at a skewed angle, but the equipment's primary purpose was to stop a small piece of rogue metal from taking a soldier out of combat.
Fast forward to the twenty first century and soldiers can now be equipped with plate carriers that can reliably stop intermediate rifle rounds such as what the AK-47 and M-16 fire, as well as full-power rifle rounds like what an M-14 or older World War II rifles would shoot. The plates put into such vests can be pulled out and replaced, and the vest itself acts as a load-bearing tool to carry spare ammunition and supplies on, so it has a purpose beyond what something like the SN-42 would have served. Cheers!
Body armor experienced a brief period of semi-irrelevance in the 1800s and 1900s. The term "Bulletproof" comes from the days of full-plate mail, called plate harness. When firearms began to appear on the battlefield, armor users naturally wanted their armor to be able to protect them. Armorsmiths understood metal and crafted suits that did the job. These were tested by loading up a pistol real hot and firing at the armor from a close distance. The resulting dent was the proof mark, hence "Bullet Proof". As firearms became more powerful, and specialist ammunition to pierce armor was developed (the APFSDS -Armor-piercing, Fin-Stabilized, Discarding Sabot- round is not new at all, something like a crossbow bolt would be fashioned, with fletching for spin and a hardened steel point for penetration, and placed in a two-piece wooden shell the diameter of the bore of the gun. This round, while much more complicated to make than a lead ball, could defeat armor), plate harness declined because of the ever-thicker plates required to stop the faster and better-penetrating rounds. This decline hit its nadir around the 1800s/1900s, with only elite heavy cavalry units retaining their now-quite-thick steel breastplates and helms.
As early as the American Civil War, their was consideration of making ballistic vests standard issue (contrary to what you may understand, soft ballistic vests are not a new idea, in this period such a vest was made from many layers of tightly woven silk or cotton, and was indeed effective against the soft lead bullets then in wide use). In fact Archduke Ferdinand was wearing such a vest when he was assassinated- he just happened to get shot in the neck. They were also common with prohibition-era gangsters. Many soldiers in the Civil War bought their own ballistic vests, and many unscrupulous persons profited from the sale of the ballistic-vest equivalent of a wooden nutmeg. Vests were not adopted due to cost reasons, these fabrics were very expensive in the requisite amounts.
The worm turned in the First World War, in the stalemate of the trenches. French heavy cavalry, the Cursassiers, were dispatched to the fight, where they dismounted and joined others in the trenches. As their name implied, they wore the cuirass, a heavy breastplate of ballistic steel, although the cordite-charged, pointed, jacketed bullets of that war could penetrate it under some circumstances. Chiefly, they also wore a steel helm. It was discovered that they took many fewer wounds than their unarmored comrades, and the discussion began to happen about issuing armor again to everyone.
At first a steel skull-cap, worn beneath the hat, was used. It was a good change, but it was decided that a fully metal hat would offer more protection. Thus was born the brimmed, steel hat which we associate with the Entente powers. The Germans entered the war wearing the Pickelhaube, the iconic helmet with the spike on top. The overwhelming majority of these helmets were formed from hardened leather -good protection from knocks and bumps and melee combat, but not so much against metal splinters and nearly useless against bullets. They too developed a steel helmet, the stahlhelm, whose design became standard for armies the world over and today most soldiers wear a helm whose pattern follows the stahlhelm. The "Steel hat" "Brody Helmet" style has almost completely vanished and the skull-cap was stillborn.
There was a notable stumble that almost set things on their ear, once steel helmets were being issued, it was discovered that the number of troops in hospital with head-wounds had actually increased. The reason for this is that no helmet is perfect, and a bullet or splinter that pierces a helmet and wounds a man in the head would very likely have killed him outright absent the helmet, and so he goes to the aid station as a casualty instead of the morgue as a corpse.
Of all the pieces of armor, a helm is the most important; if you must go into combat it is the top priority; your head is your most vulnerable part and the hardest to set right if wounded. When soldiers would simply show up to war with their own kit, the helmet was the first thing to be procured in terms of armor; if you could afford nothing else armor-wise but a helmet, you were much better off than he without armor at all. This is a fact of man, not arms, and so has not changed. If funds prevent provision of full armor to everyone, you provide helmets.
Modern soldiers are more expensive per unit-cost than in the past, and modern armor can reliably stop rifle rounds while still being able to be worn somewhat comfortably, so the expense is well justified. The US, at least, has shied away from conscription, and strives to protect its volunteers well, so giving every combatant armor makes good sense. In WWI and WWII, specialist troops were indeed issued heavy steel plate armor that protected against bullets (no armor is completely "Bullet-Proof" in the common sense of "stops all bullets", but then, as now, hardplate stops a lot of the angry bits of metal that want to intrude upon your peaceful organs' repose.