What does that have to do with anything?
has something to do with = 有(某种)关联
has anything to do with = 有任何关联
“What does that have to do with anything? ” means：
Just to add: You can't say "What does it have anything to do with that?" because "what" and "anything" would both be objects of "have." It's like asking "What did you eat fish yesterday?" But you could say "What does it have to do with that?"
'have to do with' is something like 'relevant to'. If I ask you if you want to go skiing this weekend, and then you answer by saying that your father just got a nice haircut, then I can say, 'What does that have to do with anything?' - as in, how is your father's haircut relevant to the subject of skiing this weekend?