In October of 1962, the US saw that the USSR was building missile sites in Cuba.
Of course, JFK did not want the Soviet Union or Cuba to find out that he knew about the missiles. He met with his advisors and they discussed what to do; they did not want USSR missiles so close to the US, but they also did not want to anger the Soviets and risk a nuclear war.
After the meetings, the president decided to put a blockade of ships around Cuba. This prevented the Soviet Union from bringing more supplies in. He also told them to take back the missiles and destroy the sites.
Nikita Khrushchev, the leader of the USSR, also wanted to avoid a nuclear war and decided to agree to the US's demands. This was important because both of the two superpowers of the time acknowledged the power of the other, and they avoided a nuclear mess that could have wiped out both of the countries completely.