I would say that the debate depends on how close the Japanese Government was
perceived to be to surrender.
How close they
really were is an appeal to hindsight and thus inappropriate when judging the actions taken at the time.
But more importantly, I think the debate depends on the
principles for using force in war: Military necessity, distinction, and proportionality.
Military necessity has been addressed upthread. The cities were legitimate military targets according to the way of war at the time. See also:
http://en.wikipedia.org/wiki/Military_necessity
Distinction is the principle by which belligerents must distinguish between military and civilian personnel, and treat them differently in some contexts. This has also been much debated in this thread. Some introductory info can be found here:
http://en.wikipedia.org/wiki/Distinction_(law)
Proportionality is the principle that the amount of force used must be proportional to the military value of the target. Note that this is not a principle that force should be proportional to the enemy's force. The enemy's strength doesn't matter here, only the military value of defeating them in proportion to the civilian lives put at risk in the process. If no civilian lives are at risk, the principle of proportionality under international law allows you to defeat a ragtag band of rebels with a massive artillery barrage. More about proportionality:
http://en.wikipedia.org/wiki/Proportionality_(law)#International_humanitarian_law
The way I see it, there were at least two sound military reasons to use nuclear weapons on Japan, and several beneficial results that also have merit. So for me, choosing a justification for the attacks was never a question of "either, or", but rather "yes, and".
Yes it destroyed significant military targets with proportional force,
and it demoralized the enemy and hastened their surrender,
and it gave military planners good info on the effects of the new weapon,
and it demonstrated the new deterrent to the Soviet Union. What's not to like?