The Republican Party has historically been in favor of space exploration ever since the Space Race began
The Space Race is generally agreed to have begun in 1955, when both the US and the Soviet Union announced that they were going to launch artificial satellites during the International Geophysical Year (1957-58). With the Soviets successfully launching Sputnik 1 before the Americans were able to launch their own satellite, competing with the Soviets in space exploration quickly became viewed as imperative to maintaining national security (the main reasons being that, orbital spaceflight capability also implies the capability to deliver nuclear weapons to any location on Earth).
Dwight Eisenhower was the President of the United States in 1955, and a Republican. In light of the difficulties with the Americans to compete with the Soviets, Eisenhower actually called for the creation of a single civilian agency to manage non-military space exploration activities. That agency is the National Aeronautics and Space Administration, which still exists today.
Richard Nixon was Eisenhower's Vice President. He played a very significant role overseeing these activities, and then later became President just as the Apollo Program finally started landing men on the moon. He was very personally enthusiastic about space exploration, and wanted to pursue missions beyond the moon. Unfortunately, the public and Congress were less willing to spend money on space exploration given the Soviets were seen as having been beaten and there were other priorities for the money, so most of those ambitious projects were scrapped. The one project that remained was the Space Transportation System, a part of which did get built that was more commonly known as the Space Shuttle.
Ronald Reagan was very supportive of the Space Shuttle program because he viewed it as necessary part of the Cold War. If anything, you could say he was too invested in it; some people claim his administration's involvement in the Space Shuttle program led to the Challenger disaster, specifically through trying to portray what was an experimental spacecraft (read: a very dangerous vehicle) as an operational one (read: a vehicle safe enough to have school teachers riding on it on a regular basis).
George W. Bush was also interested in spaceflight and started the Constellation program, whose goals were to return to the moon and then explore Mars. This program got cancelled, but we got the current Orion space capsule and the Space Launch System out of it.
The Democratic Party has actually been less in favor of space exploration than most people think
Most people think of John F. Kennedy when they think of American space exploration, thanks to his rather famous speech where he announced that Americans would land a man on the moon and return him safely to the Earth before 1970. The truth was Kennedy was originally lukewarm at best about the space program until the success of Project Mercury made him realize it was a politically useful way to compete with the Soviets, especially given that he had several scandals at the time (notably, the failed Bay of Pigs invasion of Cuba).
Lyndon Johnson was President after Kennedy, and although he was publicly a vocal proponent of space exploration, he also wanted the massive amounts of money that were being spent on it to be used for other purposes, specifically the Vietnam War and the Great Society. He was responsible for cutting back Saturn rocket production back from the original planned levels, effectively shortening the Apollo program and any follow-on efforts using that technology (e.g. the Apollo Applications Program and Skylab).
Barack Obama's administration cancelled the Constellation Program, and pursued the Commercial Crew Program specifically as a way for the government to spend less money on space exploration. Which... turned out great, actually, because we got a lot of cool stuff from SpaceX out of that at bargain-basement prices.