According to World Wide Words, it originates from firemen doing speed competitions without carrying water.
The term run, more fully fire run, has for at least the past century been used by local fire departments in the USA for a call-out to the site of a fire. It was once common for fire departments or volunteer hose companies to give exhibitions of their prowess at carnivals or similar events. [...] These competitions had fairly standard rules, of which several examples appear in the press of this period, such as in the Olean Democrat of 2 August 1888: “Not less than fifteen or more than seventeen men to each company. Dry run, standing start, each team to be allowed one trial; cart to carry 350 feet of hose in 50 foot lengths ...”.
These reports show that a dry run in the jargon of the fire service at this period was one that didn’t involve the use of water, as opposed to a wet run that did. In some competitions there was a specific class for the latter, one of which was reported in the Salem Daily News for 6 July 1896: “The wet run was made by the Fulton hook and ladder company and the Deluge hose company. The run was made east in Main street to Fawcett’s store where the ladders were raised to the top of the building. The hose company attached [its] hose to a fire plug and ascending the ladder gave a fine exhibition.”
It’s clear that the idea of a dry run being a rehearsal would very readily follow from the jargon usage, though it first appears in print only much later.
Dictionary coverage of 'get cracking'
J.E. Lighter, Random House Historical Dictionary of American Slang (1994) reports that "get cracking" came into U.S. English from the UK during the 1940s:
get cracking to get busy; get going. {This phr[ase] came into U.S. speech through contact with British armed forces during WWII.}
Lighter's first citation for the phrase is from Eric Partridge, Dictionary of Slang and Unconventional English (1936), as "Get cracking, begin work."
It appears to have caught on as a naturalized phrase fairly quickly, however, since it appears in Harold Wentworth & Stuart Flexner, Dictionary of American Slang, first edition (1960):
cracking, get Start; start moving; begin working; begin to exert oneself. Often in the phrase let's get cracking.
The entry for "get cracking" in the original edition of Eric Partridge, Dictionary of Slang and Unconventional English (1936) is actually a bit more detailed than Lighter's citation suggests:
get cracking. To begin work : Royal Air Force : from ca. 1925. I.e. cracking on speed.
Earlier in the same dictionary, Partridge has this entry for cracking as an adjective:
cracking, adj. Very fast ; exceedingly vigorous (-- 1880) : slightly ob[solete, in 1936]
By the fifth edition (1961) of the dictionary, however, Partridge had evidently rethought the place of "get cracking" in the larger scheme of similar phrases and had adopted the entry that ghoppe reports in a different answer here, with the suggestion that it might have its origin in "whip-cracking at the mustering of cattle."
Early Google Books matches
Google Search results generally support Partridge's1936 reading of the phrase. The earliest relevant matches are from 1938, and one of them is RAF-specific. From Popular Flying, volume 6, issue 9 (1938) [combined snippets]:
We've got a new vocabulary in Black Bourton, the vocabulary of the R.A.F. Nice things are "wizard"; nasty people are "ropey types," and a reckless man is "split." One is "browned off" when one is rather depressed; the ground is the "deck" and the sky is the "ceiling"; dull-witted people are "drips," and when in a hurry we ask each other to get "cracking." This strange lingo is, of course, subject to changes and ex-R.A.F. men of several years ago would find themselves hopelessly dated by the expressions they use.
There is, however, one outlying instance of "got cracking"—or more precisely "got cracking away"—that might be significant as well. From Bertram Milford, In the Whirl of the Rising (1904), a novel seemingly set in Rhodesia during the Second Matabele War, of 1896–1897:
"You must have had the very devil of a scrap, Peters." one of these [horsemen from Green's Scouts, a relieving force] was saying. "We could hear you banging away from the time you began, and pushed our gees for all they'd carry; for we reckoned all that shooting meant a big thing and no bally skirmish. ... They [the Matabele forces] didn't know we were there till we got cracking away right in their faces, or mostly backs. Magtig! Didn't they skip. ..."
Here it seems pretty clear that "got cracking away" means "started firing our guns." Is this usage connected to the later World War II use of "get cracking"? It's difficult to say. If there is a connection, the literal slang term for gunfire would have to have transmuted into a more figurative sense of getting started. Still, both usages have a strong tie to military usage, and a connection is not impossible.
Conclusion
No reference work has convincingly tracked "get cracking" to its original lair. The term does seem to be of UK English origin, but whether it originated in the RAF in 1925, or in Rhodesia in the late 1890s, or in some bucolic setting to the sound of bullwhips bring cattle into order for transportation or migration remains unclear.
Best Answer
This appears to have originated in the First World War, of which long, drawn-out trench warfare was a defining aspect, especially of the western front.
From a summary of Guy's Hospital Gazette (1914):
From a snippet of The New York Times Current History of the European War (1915):
The same phrase was used of the First World War such as The Fight for the Future (1916) by Edward Arthur Burroughs (Bishop of Repon)
The same phrase, or variations thereof, have been used to describe wars in Algeria, Vietnam and Iraq, and often given as the definition of war, or at least war at the front.
Edward Bolland Osborn writes in The New Elizabethans: A First Selection of the Lives of Young Men who Have Fallen in the Great War (1919) of:
...
...
...
George A. Birmingham's A Padre in France (1918):
This is a serious problem for the military. A paper called Hours of Boredom, Moments of Terror Temporal Desynchrony in Military and Security Force Operations (Peter A. Hancock and Gerald P. Krueger, National Defense University, 2010, PDF) addresses this problem and concludes: