1) .gov aka "G-job" means you can't talk about it, maybe even to your boss. Maybe you're making the left support bracket for the Manhattan project, no one in 100 miles knows what you're actually building. Maybe no one knows everything about the whole program. So you're kinda on your own in the machine shop, kinda.
2) Wanna build a model steam engine at work? Tell them the crankshaft is a classified part for some contract you can't talk about and they're not cleared to even see the blueprint.
3) But screwing around for fun doesn't have to be made to the tolerances for real a-bomb parts... So "close enough for govt work"
The other story I heard from oldtimers who were there, was there was an intense push in the early 40s to shovel as much out the door as possible. An automobile plant used to selling to rich dudes wouldn't dare ship a car with cosmetic issues, but tank crews don't care if there's a little weld splatter on the outside or runs in the paint, as long as it actually works in combat. And this created attitude issues when they converted back to making fancy cars for rich dudes after the war. "So there's a giant dent in the hood, the GIs don't care... Uh, yeah but we're not building jeeps anymore..."
If you do a google ngram search on the phrase, you'll see a blip during WWII and then nothing until 1970. I'm guessing the use from 1970 onwards probably carried the negative connotation we're all familiar with.
Euphemism for "standing around outside - a lot"