Prior to the Communist revolution in 1959, the United States and Cuba had a good relationship. Americans flocked to Cuba for its resorts, serene beaches, and rich culture. From the 1920s to the 1950s, Cuban music was the guiding force in the development of American popular dancing. Ernest Hemingway lived on Cuba for 22 years, and American culture infiltrated every aspect of Cuban life.
But when Fidel Castro came to power in 1959, relations between the United States and Cuba quickly deteriorated. U.S. President Dwight Eisenhower officially recognized Castro's new Communist government, but the United States was greatly disturbed by having a Communist nation in the Western hemisphere (just 100 miles off the coast of Florida, at that). Eisenhower imposed trade restrictions on Cuba and started planning an invasion to overthrow Castro, which President John F. Kennedy carried out in 1961. But the Bay of Pigs invasion, as it was called, was a disaster — the Cuban army defeated the Americans in only three days. Between 1960 and 1965, U.S. forces attempted to assassinate Castro more than eight times.
Tensions between the two nations peaked in 1962, after U.S. spy planes discovered that the Soviet Union was moving intermediate-range missiles to Cuba, and pointing them at the United States. War seemed inevitable, and many Americans who remember it count the Cuban Missile Crisis as one of the scariest events of their lifetimes.
The tension subsided when the Soviets backed down, but after the Cuban Missile Crisis, President Kennedy prohibited all Americans from conducting business (or any financial transaction) with Cuba. This embargo continues today, and the two nations have had no diplomatic relations since 1961 (although both sides occasionally like to pound their chests and bicker at each other). The relationship is so bad that when United States and Cuba do have a legitimate reason to talk to each other, they use Switzerland as a mediator.
Turning to Nicaragua, in the late 1970s a revolutionary group called the Sandanistas seized power and launched a plan to create a Marxist-style government, looking at Castro's Cuba as a template. At first, the U.S. President Jimmy Carter tried to work with the new government, but soon he began setting the stage to support a counter-revolution. But in 1980, newly elected U.S. President Ronald Reagan turned toward Central America as a large part of his foreign policy. Reagan had a particularly strong opposition to "Cuban-style communism" in Nicaragua.
Throughout his presidency, Reagan assisted Nicaraguan counter-revolutionaries (a group called the Contras) with intelligence, weapons, and money (some supplied legally, some not). Reagan was determined to keep Central America free and Communism off "our doorstep." Depending on which side of the political fence you fall on, you may view Reagan as a hero for his actions (and the reason that today, Communism has been mostly defeated in Central America) or as one step above being a war criminal.