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 rising sophomore studying linguistics and government at Harvard University, has been described as the internet's sixth most famous etymologist. He also has disturbing interests in politics, vexillology, geography, board games, conlanging, and law.