Why doesn't Donflamingo control Luffy? Donflamingo can control people using his strings. Why doesn't he use his ability to control Luffy, or Law instead of fighting them?
I think Doflamingo can only control those who are weaker than him with his strings. 

The most powerful man he has been shown affecting with his strings by far is Jozu, but he didn't control him in the same way he did Bellamy, he just froze him still. Jozu couldn't move, but Doflamingo didn't move him around like a puppet either, whether because he couldn't or just didn't bother isn't clear. 

I suspect that for people far weaker than Doffy, like Bellamy or Riku, he is able to completely control their movements, for those weaker than himself he is able to stop their movement, but not move them like a puppet, and that those stronger than him, like presumably Kaido, are able to move freely even when he's trying to control them.

Almost no-one in One Piece has any absolute powers, I don't think Doflamingo's puppet ability is magic, I think he is just able to exert a great deal of his strength through his strings. I think Luffy and Law are at the level that Doflamingo could perhaps stop their movements, but he wouldn't be able to puppet them around like Bellamy.