We were taught in school about the bombing in very jist. I googled and watched a bit of documentaries and still unsure of facts. It was response to attack on pearl harbour but pearl harbour had military ships.
The section The Atomic Bombs in the FAQ (FAQ/World War II/The Atomic Bombs) may be of interest, in particular "Did the US *have* to nuke Japan in WWII?," "Were the Japanese planning to surrender before the dropping of the atomic bombs?." both by /u/restricteddata
Additionally, the subsection "Atomic Bomb Targeting" might be of interest