Kennedy's assassination is probably the only reason we walked on the Moon
PBS had a really good documentary about this recently. Shortly before his death he was already having to fight congress (which his own party controlled!) for sufficient funds, and NASA was already running into delays that threatened to push the timetable past the end of the decade.
The reason we were able to maintain a national will to go the Moon and spend what needed to be spent to do so, was primarily in his memory. If not for that, and especially if he'd been voted out in 1964, it would have ended up on the scrap heap along with every other president since Reagan (I don't think he talked about going to the Moon or Mars) who at one time or another wanted to channel their inner Kennedy and announce another "moonshot". They've all disappeared under the waves within a couple years, to the point where when Obama and now Trump talk about it, people just laugh because we know damn well nothing will happen. Even if funds to make it happen are budgeted for the first year, as costs begin to rise it is an easy cut to make to allow funding another budget initiative while claiming "no increase of deficit" for that initiative.
For all the complaints people had about Nixon as a president, the words he said when we landed on the Moon were as historic and noble as the words Kennedy uttered when he made going to the Moon a national priority. Imagine if Trump was president when that had happened, he'd first take credit for it claiming "no other president could have done this", then complain about the Mueller investigation and democrats, and for a finishing touch add a little white supremacy by praising Von Braun and "say what you want about Hitler, he knew rockets, if it weren't for the Nazis we couldn't have gone to the Moon. They did a lot of bad things, but they did a lot of good things too. There were very fine people - on both sides - of WW II".