I'm pretty sure the US even sent out flyers that said for people to move out of the cities before they bombed it. So why was a civilian city targeted instead of a military base? It would seem much more beneficial to bomb an enemy's military base/command center/whatever than a city.
You can read the minutes of the May 1945 Target Committee meeting online. They are more interesting and provocative than any simple summary can give you, and they are "straight from the horse's mouth," as they say. The short answer is they wanted it to be a spectacular display, that they deliberately chose military targets located within urban areas to maximally display the damage, and that Nagasaki was actually quite a minor target (it was added to the final target list only after Kyoto was removed, and was not the primary target for the second bomb).
As the Target Committee meeting makes clear, the primary consideration was the "psychological effect" of the use of the bomb, not a military result:
It was agreed that psychological factors in the target selection were of great importance. Two aspects of this are (1) obtaining the greatest psychological effect against Japan and (2) making the initial use sufficiently spectacular for the importance of the weapon to be internationally recognized when publicity on it is released.
They also concluded:
It was agreed that for the initial use of the weapon any small and strictly military objective should be located in a much larger area subject to blast damage in order to avoid undue risks of the weapon being lost due to bad placing of the bomb.
Anyway. It is worth reading, if you are interested in reconstructing their point of view from the time, and not the later justifications that were offered up when people started to question it (including other American military commanders, many of whom began to publish statements claiming the atomic bombs were unnecessary).
There were no warning leaflets about the atomic bomb dropped prior to the bombs themselves; that is a myth.
Hi there -- while there's always more to be said on this topic, this section of our FAQ deals specifically with atomic bomb targeting, while this answer from u/restricteddata deals with the question of warning leaflets.