IMO, it was a wrong move. The reasons are:
1. Why free 5 terrorists for just one soldier? At the most the Americans should have freed one terrorist.
2. It will encourage the Al Qaeda to take more American hostages (both civilian and military).
3. It will affect the morale of the troops.
1 - It comes down to the perceived of each individual. If Al Qaeda values each of their terrorists at a rate of 1/5 that of the rate that the US values each of it's soldiers then it would be a fair trade (is this regard only)
2 - You are correct, although this is not really what they are in the "business" of doing as they are more of a inflicting terror organization then a hostage taking organization. It would encourage other groups to take hostages.
3 - Probably not, the US is big on not leaving any soldiers behind so saving a soldier should actually increase morale (there is however an asterisk to this statement).
The biggest issue with this deal is that there are reports that he had deserted his post shortly before being captured. I do not think it is appropriate to reward people for this kind of activity