The Lonley Planet guide to Nicaragua has a readable history of the nation which has been excerpted below.
In 1934, General Somoza, head of the US-trained National Guard, engineered the assassination of liberal opposition rebel Augusto C Sandino and, after fraudulent elections, became president in 1937. Somoza ruled Nicaragua as a dictator for the next 20 years, amassing huge personal wealth and landholdings the size of El Salvador. Although General Somoza was shot dead in 1956, his sons upheld the reign of the Somoza dynasty until 1979. Widespread opposition to the regime had been present for a long time, but it was the devasting earthquake of 1972, and more specifically the way that international aid poured into the pockets of the Somozas while thousands of people suffered and died, that caused opposition to spread among all classes of Nicaraguans. Two groups were set up to counter the regime: the FSLN (Frente Sandinista de Liberacion Nacional, also known as the Sandinistas) and the UDEL, led by Pedro Joaquin Chamorro, publisher of La Prensa, the newspaper critical of the dictatorship.
When Chamorro was assassinated in 1978 the people erupted in violence and declared a general strike. The revolt spread and former moderates joined with the FSLN to overthrow the Somoza regime. The Sandinistas marched victoriously into Managua on July 19, 1979. They inherited a poverty-stricken country with high rates of homelessness and illiteracy and insufficient health care. The new government nationalized the lands of the Somozas and established farming cooperatives. They waged a massive education campaign that reduced illiteracy from 50% to 13%, and introduced an immunization program that eliminated polio and reduced infant mortality to a third of the rate it had been before the revolution.
It wasn't long before the country encountered serious problems from its 'good neighbor' to the north. The US government, which had supported the Somozas until the end, was alarmed that the Nicaraguans were setting a dangerous example to the region. A successful popular revolution was not what the US government wanted. Three months after Ronald Reagan took office in 1981, the USA announced that it was suspending aid to Nicaragua and allocating US$10 million for the organization of counter-revolutionary groups known as Contras. The Sandinistas responded by using much of the nation's resources to defend themselves against the US-funded insurgency.
In 1984, elections were held in which Daniel Ortega, the leader of the Sandinistas, won 67% of the vote, but the USA continued its attacks on Nicaragua. In 1985, the USA imposed a trade embargo that lasted five years and strangled Nicaragua's economy. By this time it was widely known that the USA was funding the Contras, often covertly through the CIA, and Congress passed a number of bills that called for an end to the funding. US support for the Contras continued secretly until the so-called Irangate scandal revealed that the CIA had illegally sold weapons to Iran at inflated prices, and used the profits to fund the Contras.