There's quite a bit about this in our FAQ that may answer your question:
https://www.reddit.com/r/AskHistorians/wiki/wwii#wiki_the_atomic_bombs
The short version takes two forms:
Hiroshima and Nagasaki were not "the cities that were going to get bombed." The Army Air Force had been bombing and firebombing cities across Japan well before late 1945, when the atomic bombs were dropped. (I say this to point out a common misconception about the bombs, which is where people think those were the only two cities that were targeted.)
Hiroshima in particular was on a list of targets for atomic bombings; these cities were chosen to be spared conventional bombings to be a better demonstration of the power of atomic bombs. Nagasaki is in a different category, it was a backup target and was bombed after Bockscar found that its primary target (Kokura) was obscured by smoke.
These posts from the blog of our resident atomic expert, /u/restricteddata, that may be of interest to you:
http://blog.nuclearsecrecy.com/2013/03/08/the-decision-to-use-the-bomb-a-consensus-view/
The original target choices in May 1945 were Kyoto, Hiroshima, Yokohama, Kokura, and Niigata. All were cities with military and industrial relevance, but not such high priority that they were likely to be immediately bombed. A list of "Reserved areas" to prevent them from being firebombed (to save them for atomic bombing) was created for Kyoto, Hiroshima, and Niigata. Yokohama was firebombed right after the reserved list was created, and thus off the target list.
Kyoto was removed from the target list at the request of the Secretary of War, who did not want to see it bombed. Kokura was added to the "Reserved Areas" list late June.
The military representatives fought to get Kyoto back on the list, but were resisted. Nagasaki was added at pretty much the last minute as a backup target, right before the final strike order was issued on July 25th, 1945. It was not a high-priority target and had already been bombed several times.
The first atomic bombing mission on August 6th, 1945, had its primary target Hiroshima, secondary Kokura, tertiary Nagasaki. (Niigata was much further away.) Hiroshima had the advantage of being geographically well-situated to be damaged by the kind of blast an atomic bomb produces, and its many rivers made it a poor firebombing target. The second atomic bombing mission on August 9th, 1945, had its primary target Kokura, secondary Nagasaki. Kokura was a much better target from a logistical point of view than Nagasaki (it was a large arsenal surrounded by urban houses, so a well-placed bomb would do a lot of damage, primarily military/industrial), but it was obscured by smoke or haze of a not completely known origin. The bomber moved on to the secondary target, Nagasaki. Nagasaki was also obscured by smoke/haze/clouds but they dropped it anyway, probably disobeying orders about having visual confirmation of the target. The area they dropped the bomb in was almost entirely civilian (there were military factories on the fringes, but the main things destroyed were houses and schools), and the hills of Nagasaki drastically reduced the area of destruction compared to Hiroshima. If the bomber had not released the bomb when it did, it would have probably had to abort the entire mission and sacrifice the bomb into the ocean. It was not a very smooth mission from an operational point of view.
After the bombing people talked about Nagasaki as if it had been as carefully chosen and thought-out as Hiroshima but this is just not the case. It was literally scrawled in by hand at the last moment, and was not a great target for a lot of reasons.