It is to emphasize
the word "fuck." It comes from the shorter version of "give a fuck" and then "give a
flying fuck." It means "I don't care" but with emphasis. So it is an emphatic "I don't care!" Or also, emphatic "I
could care less."
"I don't give a flying dog fuck if you want to go to the
beach, we are NOT going!"
"I don't give a flying dog fuck if you
like driving, I am doing the driving!"