Wouldn't it have made the surrender of Japan much surer if the bomb would've succesfully gone off in Tokyo where, I assume, much more people lived?
Or am I sounding like a complete idiot now?
This is actually pretty straightforward. There was a committee appointed to choose a site that met certain criteria. While Tokyo (and the Emperor's palace) was well known, it didn't necessarily harbor major strategic value or major industry devoted to fueling the Japanese war machine.
The committee decided the target had to be urban (meaning lots of casualties and destruction of infrastructure), the bomb would be causing major damage, and the target would have to be a place that seemed safe to the Japanese, and not able to be attacked before the end of August in 1945, when the US hoped to end the campaign.
Hiroshima was selected because of the major port and industry in the area, and because it was also a poor target for fire bombing, being that multiple rivers ran through the area.
Nagasaki was very similar in that it contained plenty of industrial manufacturing concerning the war effort, and a large sea-port. It was only chosen as a target later, when Kyoto and even Tokyo were condemned as targets by Truman himself. He noted in his diary as follows:
...we as the leader of the world for the common welfare cannot drop that terrible bomb on the old capital [Kyoto] or the new [Tokyo]. He and I are in accord. The target will be a purely military one.
Edit: Sources
Minutes from the second meeting of the Target Committee, May 10-11,1945
You can read the deliberations of the Target Committee from May 1945 here. The criteria for the first bomb targets were that:
(1) they be important targets in a large urban area of more than three miles in diameter, (2) they be capable of being damaged effectively by a blast, and (3) they are unlikely to be attacked by next August.
Tokyo met the first two criteria, but not the third. Tokyo had already been subjected to ruinous incendiary bombing starting in March 1945. It was burnt out to the point that some of the photos of it are easily confused with photographs of Hiroshima and Nagasaki (Tokyo is on the left, Hiroshima on the right).
You will also note from the document that:
(6) The possibility of bombing the Emperor's palace was discussed. It was agreed that we should not recommend it but that any action for this bombing should come from authorities on military policy. It was agreed that we should obtain information from which we could determine the effectiveness of our weapon against this target.
Which to me indicates that they considered this to a question of very high military policy, whether to attack the center of political power.
Plus the reason to bomb was to force them to quit, not destroy them as a nation. Bombing Tokyo would have ramifications that would probably still impact technology and relations today.