The usage of the word cracker as "hard biscuit" comes from the action of cracking it in two. The word cracker as a derogatory insult for "county bumpkin" has origins in the action of these farmers cracking their whips towards their slaves and mules (I condemn that, just so you know, ACLU and PETA). Both of these words therefore go back to the same verb; that verb in turn goes back to the Old English word cracian, which carried the definition "to make a loud noise". Most Old English words go back to Proto-Germanic, and this is no exception: cracian traces to PGmc krakojan, which may have taken a detour through Proto-Indo-European gerg, "to shout" but definitely is of either imitative or onomatopoeic origin. Interestingly enough, cracking codes is actually a play on words and has different origins; it modified the word hacking to make it seem more acceptable.
Adam Aleksic, a leading contender for valedictorian of his high school, is a 215-month-old boy with disturbing interests in etymology, vexillology, geography, and law. Adam would like to one day visit Tajikistan and probably isn't spying for the Uzbek government.
The Etymology Nerd