It seems that motorcycles were employed by armed forces at a very early stage, no later than 1916, when the US army made use of them during their expedition to Mexican territory aimed at capturing the Mexican revolutionary Pancho Villa. After that episode, motorcycles were in high demand for armed forces in general, having been deployed in theatres of war in various conflicts.
In an age when cavalry still played a major role in the military, motorcycles were appealing for their speed, agility and range. Enhanced with added parts such as armour and guns, they became indispensable on the ground, not only as combat units on their own, but also as a fast and trustworthy way to convey ammunition or weapons quickly across the battlefield. Their main function turned out to be the transmission of messages, in an era pre-dating reliable electronic communications.
With the adaptation of warfare to modern technology, the need for motorcycles in regular combat has decreased sharply, yet they are still to be found in elite troops, where state of the art models are still very much relied upon for specific operations in a variety of terrains and conditions.