Sort of a mild expletive of the drat, sugar and shoot variety; in other words, a word that sounds a bit like a swearword.
I can only presume that dagnabbit is a corruption of God damn it. However I've never heard an equivalent corruption of the adjectival form "goddammed".
It's sort of a funny exclamation in any case. It seems to belong in Westerns, as the shout of some old man with a mustache cursing those varmints who steal his carrots, or whatever.
The term has gained a place in modern language as a post-modernist ironic shout when something really minor happens, like "Dagnabbit, my shoelace is untied".
I had always thought that this word was dagnammit, which seems an acceptable varient, though not as common. So are 'dagnabit', 'dagnamit' and 'daggnamit' -- at least according to Google.