Drill is marching, plain and simple. In ancient times, the most powerful, efficient, and developed empires developed ways of moving troops from one place to another without them getting mixed up with other troops. So they marched together from one place to another, also known as drill.
The theory was, without drill, masses of soldiers would end up getting lost on the way to battle and have to fight with just any ol' unit they could find,instead of the unit they trained with.
As time went on, a system of flags developed. These flags allowed soldiers to find their own units (and side) on the battlefield if they got lost. However, the military quickly discovered that sticking to formed units worked better, as everyone was present when needed for battle.
Overall, the drill system worked: Soldiers stayed together and could be commanded as a group.
These days, military drill is mostly used for military ceremonies, such as military parades, and to instill pride and discipline during military training (such as basic training). In fact, the military drill manual (a book about 6 inches thick) confidently states that drill is the foundation of discipline in battle, and that its importance has been proven again and again.
For example, back in 2002 and 2003, when the North Koreans claimed that they were developing nuclear weapons, they conducted a huge number of public military parades, receiving lots of attention from the press, which commended them on how modern and disciplined their military was. The North Korean forces could clearly be seen to be skilled, which would act as a deterrent against many lesser military forces.
Today, regular parades in public display the military as a highly trained, disciplined, and professional force. Even though the parade itself doesn't provide any useful function on the battlefield, it instills public confidence in the nation's military forces. A rag-tag military is likely to be unable to put on parades, so it holds that larger and better military forces can display their discipline by means of public performances.
From Basic Training for Dummies, copyright © 2011 by Wiley Publishing, Inc., Hoboken, New Jersey. Used by arrangement with John Wiley & Sons, Inc.