This was the right thing to do. He's worth the money. If it makes him happier player and a believer in the idea that if he does well here that he will be fairly rewarded for it in the end, That's a plus.
It sucks to lose the cap space, but he deserves it. If you see the list of offensive skill players being paid more than him you would laugh at what a steal a deal like this appears to be by comparison.
As far as the cap space. Jason McCourty being cut would save the Pats. about 2.5M and Gillislee being cut would save about 1.4M. Not that they couldn't afford to pay this in either case. But it's nice to see it would likely just be offset easily by these moves.