"To bite the dust" means to die or to fail (see e.g. Wiktionary). Picture someone falling down, wounded or dead, quite literally biting the dust (soil, ground, earth). Etymonline says that the first recorded appearance of the phrase is from 1750. The Phrase Finder supplies it as follows:
The earliest citation of the 'bite the dust' version [of the earlier phrase 'lick the dust', from the Bible] is from 1750 by the Scottish author Tobias Smollett , in his Adventures of Gil Blas of Santillane:
"We made two of them bite the dust, and the others betake themselves to flight."
[...]
[Samuel Butler's 19th century translation of Homer's The Iliad] contains a reference to 'bite the dust' in these lines:
"Grant that my sword may pierce the shirt of Hector about his heart, and that full many of his comrades may bite the dust as they fall dying round him."
Whether that can be counted as an 8th century BC origin for 'bite the dust' is open to question and some would say that it was Butler's use of the phrase rather than Homer's.
An Ngram of the term shows its birth as a "stock phrase" only dates back to the 1960s, but the words are found in print a century earlier and the first examples of the phrase being used to mean motivating, inspiring, or enabling forces or factors go back to the 1930s. I'll give you one example of each.
I found creative juices in print back to this 1846 translation (p. 182, scroll down) of Kalevala, a Finnish epic poem that recounts a mythical story of the cursed birth of steel:
I don't think this reference is incidental. The same section of this poem, with the same translation, was reprinted several times in the writings of Lafcadio Hearn at the turn of the century and as late as 1922. While not the figurative use of the phrase we have today, I think there's a good chance its occurrence in his writings led to its familiarity and adaptation in the 1930s.
The first use of it I could find in print with its modern connotation was from this 1936 article in The Delineator:
[...] and played and replayed and recorded and wrote down their early songs.
Their creative juices dried up. Only a
few of the original players stuck by
their guns, among them notably the men
mentioned in this article. They
continued, in honky-tonks, dives and
dance halls, to play as they felt and
feel as they played.
I wasn't able to get a more complete quote because of the limitations of Google's Snippet view, but it's clear the article is referring to the figurative creative juices of musicians.
One later 1930s reference of note is found in the intro to the 1939 screenplay of Margaret Mitchell's Gone with the Wind.
Best Answer
It was first used as an interjection in the 19th century: “They marched, and I amongst them, to face the enemy – heads up – step firm – thus it was – quick time – march!”
Then, at the beginning of the 20th century, it began to be used adjectivally, as in: “He was always right on the job, and looking ‘heads up’.”
Then, around the late 70s, it became a noun, probably through shortening of phrases like “heads-up alert” into “heads-up”: “It is regarded as being a heads-up on a sale.”
Source and references: the Grammarphobia blog