There was fear that if the Russians got to the moon first they might set up a base, and having a base they could shoot down any other landing attempt (literally, with guns mounted in their moon base). Thus the moon could become Russian domain, which would not just grant them great research opportunities but also a virtually unreachable weapons platform. (Remember that the first crewed space station was 2 years after the moon landing, and also Soviet)
On that basis the military was advocating for a moon mission years before Kennedy's speech. It's hard to tell if this actually played a big role in the decision to go to the moon, but it was the cold war after all.
Also the Soviet Union was winning most of the relevant milestones in space (first satellite, first animal in orbit, first human, first woman, first space walk, etc), and this was a great source of national pride. Beating them had great propaganda value.