Dodge was a city in the midwest USA during the early part of the country's history. In that time, there was a lot of lawlessness. Bank robbers, cattle rustlers, swindlers and such. Someone caught before they actually made trouble might not be arrested, but just told to "get out of Dodge." The same phrase might be used if the bad guys had just done their bank robbing or whatever, and wanted to get away before the law caught up with them.
It just means to get out of town before you get caught. Adding 'the hell' to the phrase just makes it more urgent. You can use it even if you're not trying to escape the law, but you just want to get to some other place quickly. Perhaps because you're bored to death with the town you're in.
It can even refer to a situation instead of a town. "I can't believe that shrew Bob married. I told him that if he knows what's good for him, he should get the hell out of Dodge."