I’ve written a lot about this topic over the years. I know much more about Costa Rica than I do Panama.
For the legalities of retiring in Costa Rica go to the Association of Residents of Costa Rica/Asociación de Residentes de Costa Rica website:
www.arcr.net
The Residency in Costa Rica link tells you the different types of residency Costa Rica allows foreigners. For most, you legally cannot work. Make sure you realize that.
The point I emphasize in every article I write about this subject is not to jump into anything. Do a temporary rental and see if living day to day in the location is for you. So many people move here, thinking that living here is just like being on vacation. It is not. As a non-resident foreigner, you can stay in Costa Rica for up to 90 days. That’s a good length of time for a trial run.
Areas with large foreign communities
COSTA RICA
Escazú and Santa Ana: western suburbs of San José. (San José and suburbs sit at 3,500-4,000 feet elevation, so you have a perpetual spring-like climate all year.)
North Pacific coast: especially Tamarindo, Flamingo, and Potrero. (Potrero has a large Canadian population.)
Southern Nicoya peninsula: especially Nosara and Sámara. (Nosara has a large German and Swiss population.)
Costa Ballena: an up-and-coming area on the Central Pacific coast, stretching from Dominical to Ojochal. (Ojochal has a large Québécois population.)
PANAMA
Panama City: especially the former Canal Zone or the myriad high-rises in downtown Panama City. (Panama City gets very hot and humid.)
Again with the perpetual spring-like climate are:
Boquete: a higher elevation mountain town. (I love this place.)
El Valle de Antón: another higher elevation town, not as developed as Boquete.