It's an interesting question: At what point does keeping Hanley become better than dumping him?
As of this moment, for 2015 Hanley has been worth -0.9 WAR. In other words, in retrospect it would have benefited the team not to play him at all, despite the contract.
Let's imagine we magically know that he will improve next year to 0.0 WAR. In that case, it would behoove the team to send him elsewhere and subsidize part of the contract, even a big part. We'll get the same amount of value from him (zero), but at least it will cost less.
Now let's imagine we magically know he will improve all the way to 1.0 WAR.
If a win is worth about $6 million, then it would be smart to send him to anyone who is willing to pay more than that.
So the main two variables are: How much value can we really expect him to have going forward? And how much of his salary will another team be willing to take on? Maybe this is too pessimistic, but it sure seems like a stretch to project him for more than about 1.5 WAR. And I bet someone who actually needs a DH would be willing to pay about half his salary. If both of these statements are right, he should go.
Two other less important factors are the talent the Red Sox could get back in a trade, and the effects of advancing age on Hanley's production. Both of these factors tilt the balance in favor of a trade.
Finally, an analogy: When you have to get rid of stuff (e.g., because you're moving), very often you'll look at something and think that it might have value in the future, but right now it's just taking up space in the van. Space has value too, and if you keep that thing for its potential future value, you won't have room for another thing that has actual value right now. You should always take the first thing to the Salvation Army. If you do need one of those later, you can go get another one. Hanley Ramirez is taking up valuable space right now. He's got one of only 25 roster spots, and he's taking playing time from other guys. Keeping him around next year as a part-time DH and occasional (incompetent) fielder seems like a waste of a precious roster spot. Yes, we'll need a DH in 2017 or 2018, but that's just about the easiest problem in baseball to solve.