Obama doesn't want an American citizen, no matter how crazy, beheaded and the video feed put up on the internet during his watch. Pakistan knows this, so they keep him out of the area. After all, something like that might get the American people angry enough to demand that we roll over into Pakistan and do the job they won't. And if America invaded, you can bet that we'd take their nukes with us when we leave.
Besides that, terrorists allow Pakistan to screw around with India - see Mumbai - with plausible deniability.