*Puts on history teaching hat*
The American Naval base on Cuba dates from the Spanish-American War of 1898 (and is the oldest overseas U.S. Navy base). At this time Spain owned Cuba, and at the end of the war (August 1898) America gained control of all of Cuba from the Spanish, when the country was placed under a 20 year U.S. Treaty. On 20 May 1902 Cuba was granted it's independence from the USA, at which time Cuba agreed to lease the naval base at Guantánamo Bay to the U.S.. A perpetual lease for the area around Guantánamo Bay was then offered on 23 February 1903 (although Cuba retained ultimate sovereignty over the area). A further treaty in 1934 reaffirmed the lease and granted Cuba (and her trading partners) free access through the bay. This treaty also made the lease permanent unless both governments agreed to break it or the U.S. abandoned the base property. After the Cuban Revolution of 1959, America insisted the status of the base remained unchanged, despite Cuban objections. The Cuban government currently takes the view that the U.S. presence in Guantánamo is illegal (under the 1969 Vienna Convention on the Law of Treaties, even though this convention cannot be retroactively applied).
The Bay of Pigs Invasion and the Cuban Missile Crisis are two separate events.
The Bay of Pigs Invasion (so called because this is the area that the invasion took place) started on 15 April 1961, and ended on 21 April of the same year. It was an invasion by armed Cuban exiles with the aim of overthrowing the government of Fidel Castro. The exiles were carrying out a plan that was both conceived and funded by the U.S. Government.
The Cuban Missile Crisis occurred between 14 and 28 October 1962. The USA discovered that the Soviet Union was installing intermediate-range nuclear missiles on Cuba (which brought the USA within direct striking distance of the Soviet Union). This lead to the USA initiating a Naval blockade of Cuba to prevent the Soviets landing any further supplies. This action was declared illegal by the Soviet Union, who ordered their ships to bypass the blockade. After many threats and counter-threats, the Crisis ended with a compromise, when the Soviet Union agreed to remove all missiles from Cuba, and the USA agreed to remove all missiles from the border of the Soviet Union (they were there for NATO purposes).
This is obviously a very simplified version of all the events, as I think that I've gone on long enough here, but I hope that I've covered the basics. If anyone has any corrections then I'd be more than happy to have them.