Government clearly does matter, because crossing from Nicaragua (a relatively well organized place, it seemed) to Costa Rica was like crossing into a different world: the streams change from murky grey and trashed to clear and pristine, the landscape shifts from slash and burn farms to intact forest, and you immediately start noticing both newer, well constructed buildings and crazy amounts of wildlife.
I don't know enough about the local history to say why the difference is there, but it is immediately notable. Some thoughts from locals: government made a few lucky decisions at the right times, abolishing the military in the 50s, investing in infrastructure and social programs, and then protecting big swaths of land. Hence no civil wars (also owing to a lack of U.S. Military intervention...) in a half century, a clean environment, and a great infrastructure for Eco-tourists from the U.S. and abroad to spend their dollars. A seemingly happy, well educated population, and what seems like just the right amount of development to balance a good quality of life with a well protected environment.
I'm not sure if the equation would work everywhere in Central America, but here the country has a lot in common with some of the best functioning places: New Zealand, Canada, etc., while a place like El Salvador gets rated as among the most dangerous places in the world, particularly for citizens. There are problems here, as everywhere, but Costa Ricans travel, and return saying that home is their favorite place. Guatemalans express frustration that they can't get visas, and view their government as "mierda " (shit), for a direct quote.
All of the CA countries have been worth visiting for a lot of reasons, but CR has made it the easiest and most pleasant. It's nowhere near the cheapest, but for us it has still been more affordable than traveling in the U.S. The national and regional parks here are some of the most remarkable places I've been anywhere in the world, and Cahuita on the Carribean was the model of a tropical paradise. Go to the other places for the history, culture, interesting people, and important lessons about the way things work in countries being actively screwed by global political and economic forces. Go to CR for the counter example of possibilities for relatively resource poor countries.
PS - An interesting fact is that United Fruit- the Monsanto of the tropics, now marketed as Dole/Chiquita/Del Monte -started here with a free 99 year lease on land given in exchange for the building of a railroad that collapsed after 25 years. They are still here, more than 99 years later, actively polluting the water supplies with pesticides. Locals have encouraged us not to buy their fruit when we go home. Just passing that along! Do as you will with the info.