In Germany Maximilian Negwer founded the company "Fabrik pharmazeutischer und kosmetischer Spezialitäten Max Negwer" in 1907. The first package of Ohropax noise protectors was sold in autumn 1908 for one Goldmark (adjusted for inflation about €5.75).[…]
In August 1914, the product was recommended by Lieutenant General Freiherr von Dinklage to the War Ministry for use in the military. In 1916 the military introduced Ohropax. This was the first time that large sections of the population got to know the product, making Ohropax noise protectors the company's main product.
Translated from the sources: Wikipedia: Ohropax & Siegeszug von Ohropax begann im Ersten Weltkrieg
These plugs were initially made of wax and reduced the noise by up to 27dB. That would aid somewhat in sleep ability, but compared to noise near a gun of up to 170dB this is obviously a long way from really protecting the health of a hearing system.
This video shows Hermann Göring unplugging these protectors after he landed his plane during the last year of the First World War.
Plain and simple hearing loss and symptoms ranging up to shell shock are listed as reasons for introducing them. Previously it seems that communication ability, even if it required extremest forms of shouting were preferred and just covering the ears with your hands the only option available, despite age old stories about Sirens, Ulysses and wax. Also note that not nearly all troops would have had access to these protectors, exact numbers of plugs delivered being lost.
All this before scientific evidence could be objectively measured:
Even though damage to the inner ear by noise had been demonstrated in the 19th century, otologists could only give approximate estimates of hearing acuity in noise-exposed people, because an accurate and reproducible method of measuring hearing loss was not available until German scientists demonstrated an electronic audiometer in 1919.
In America,
Hearing protection devices (HPDs), used to guard the human ear against incurring hearing loss due to noise, have been in existence at least since the early 1900s […] In fact, in 1911, the famous band leader John Phillip Sousa complained to his friend and fellow skeet trapshooter J. A. R. Elliott that shooting traps “took a toll on his ears and was beginning to affect his livelihood [as a musician].” Elliott, being an inventor, then developed and patented (in eight countries, no less), the “Elliott Perfect Ear Protector,” and it became a commercial success (Baldwin 2004).
From: John G. Casali: "Hearing Protection Devices: Regulation, Current Trends, and Emerging Technologies", in: Colleen G. Le Prell et al.: "Noise-Induced Hearing Loss Scientific Advances", Springer, 2012, p 257–283.
Before modern research into noise induced hearing loss started really in the 1940s:
How has hearing loss been avoided in war?
But it really wasn't.
And it really isn't.
VA reported that the 2.5 million veterans receiving disability compensation at the end of fiscal year 2003 had approximately 6.8 million separate disabilities related to their military service (Veterans Benefits Administration, 2004). Disabilities of the auditory system, including tinnitus and hearing loss, were the third most common type, accounting for nearly 10 percent of the total number of disabilities among these veterans.
From: Larry E. Humes et al.: "Noise and Military Service. Implications for Hearing Loss and Tinnitus" 2006.
There are only two realistic options to protect ears from the noise of gunfire: keep away from guns, or don't use them.