Why did he do this? What possible benefit does it bring him?
There is the possibility, of course, that he did it knowing it would not benefit him. That the instant the deal was announced, the right wing nut jobs (who claim to love our military) would find a way to leverage this against him, paint him as "palling around with terrorists" again, and maybe even call for impeachment, but he did it anyway because bringing back a POW is worth a little political damage.
If we're going to be a bit more cynical, it is because Obama is concerned about his legacy. He wants to be the President that ended two wars, and leaving one POW behind will tarnish that legacy. I think this is the reason, and I wouldn't be surprised to see an effort to (rightly) empty Gitmo by the end of 2016 as well. That's five inmates down, about a buck fifty to go. As of last month, 77 of them have been cleared for release. If we can cut loose five of the worst, then the case for holding onto the ones we can let go becomes considerably weaker.
This is a good thing.
As far as the five who are being released, they are allegedly senior Taliban guys. Not Al Qaeda. Bad guys? Certainly. But bad guys who have spent a very long time in prison and we can't really justify holding them indefinitely just because they're bad guys.
Regarding the POW returning to the US, whatever crimes he might have committed by leaving his post are properly dealt with under the UCMJ. If there is punishment to be meted out, it should be done by our military, not by the Taliban.