Under Spanish rule the region suffered and quickly turned into a backwater with little attention paid to it. Being far from the Spanish center of Guatemala and with numerous trade restrictions the region fell into demise. Additionally, due to the lack of indigenous people in the region, rich Spanish settlers had little interest in the land as there was a lack of a cheap labor force, meaning most money and settlers from Europe settled in other regions.
Due to the lack of settlement in the region, there were few class or ethnic struggles under Spanish rule; perhaps the most noticeable difference in ethnicities was that many Spanish settlers moved to higher ground to avoid the intense heat of near the coasts. This blanket poverty also led to greater integration of the Spanish settlers and the local people, whether that be by intermarrying or simply in terms of better relations.
In 1821 Costa Rica, in addition to various other Central American regions claimed independence from Spain, but this solved few of Costa Rica's problems. As soon as these countries gained independence and formed a federation each fought with others over borders and power. Costa Rica also struggled in that there were still few people on the land and with little attention paid from Spain there was little infrastructure. In addition to this, there was a push from Mexico and Guatemala in 1822 to incorporate these Central American countries into Mexico. This was short lived though as Mexico received a new government the following year and gave the Central American countries the freedom to choose their futures. In 1838 this federation dissolved and Costa Rica gained full independence.
In the early 1800s Costa Rica developed their coffee growing industry, but lagged behind in terms of transporting this product. These issues were primarily settled by the mid-1800s as the country caught up to neighbors in the field of international trade. However another issue was knocking on their door as William Walker, an American who had taken over the country of Nicaragua invaded the country in 1856. The Costa Ricans won this war though and continued on their slow road of development.