JKR, the author, said in an interview that Hagrid's accent is from the same place she's from, West Country (England):
BPP2: Good question, good question. I've got another good question here ... what accent is Hagrid supposed to speak in?
JKR: West country ... where I come from, I come from the West country.
But "word of god" is the short, easy answer. It's much more interesting to look at the language.
According to this article about eye dialect, a big hint to what his dialect is comes from the rhoticity:
A clue to Hagrid’s regional background may come from the rhotocity implied by the post-vocalic ‘r’ in syllables where in the standard pronunciation variant the schwa should be present: ter, inter, tergether, etc. This rhotocity survived only in areas west of London, south of Birmingham and in Lancashire.
I think this corresponds to the red areas on this map.
That article also mentions several other features of Hagrid's speech:
The most consistent feature in Hagrid’s speech throughout the novels is the depiction of the velar nasal stop realized in the alveolar position (doin’, shakin’, murderin’). From the standpoint of phonetics, his speech is rich in such phenomena as the elision/dropping of final consonants due to colloquial speech register (an’, jus’, o’), h-dropping (musta bin) and the assimilation of sounds. Also found in Hagrid’s speech are a number of nonstandard spellings representing combinations of words (musta been, outta the ruins). These are so-called ‘junctional’ words.
H-dropping and dropping the "g" in "ing" are both mentioned as features of the dialect in the West Country English Wikipedia article. Another article says that the dialect is also signified by the grammar, including "double negatives, the use of meself instead myself, using personal plural pronouns (we, us) when referring to himself, and using the pronouns we, they, and you with the verb was".
I'm not entirely sure why he sometimes drops final consonants.
Finally, a lot of the nonstandard spellings (musta, outta, 'cept, etc.) aren't really tied to a specific dialect (as far as I know), but they just help to make Hagrid seem uneducated and lower class.