Costa Rica has always been one of the most stable countries in Central America, and there are plenty of lovely bays in which to anchor. In places, such as Golfito, where there are usually a lot of cruising boats sitting out hurricane season or waiting for the right time to cross the Pacific, there are options to leave the boat for a while and travel inland.
Be careful of unprotected anchorages during the change of seasons, when wind can switch around to blow hard a night from the "wrong" direction. When we were there many years ago several boats leaving Golfito for the Panama Canal anchored off a small island for the first night out because they didn't want to do an overnighter. In the middle of the night a storm blew up driving several of the boats onto the coral-bound shore, badly damaging the rudder of one of the boats.
Heading south, one of the first good, beautiful bays is Bahia Santa Elena in the Santa Rosa National Park. Stopping and anchoring in Santa Elena before checking in seems to be pretty common without legal issues. Around this point and just south is El Coco, the first official check-in stop for entering the country, and you should enter here. The anchorage is an open roadstead that isn't particularly comfortable, so try to get there early enough to get all your clearances out of the way so you can leave to find a better anchorage usually in Bahia Culebra (or maybe now called Papagayo, since that's what I'm finding on the internet-found map I just pulled up).
Bahia Drake (Drake Bay), just north of Golfo Dulce where Golfito is, is supposed to be a lovely bay. Lots of anchorages in Golfo Dulce.
A lot of anchorages in Costa Rica are open roadsteads. Some are fine in the winter months but not so great in the summer rainy season, so when you will be in this part of Central America will have a strong impact on the quality of the anchorages. Also, during the rainy season, the electrical storms both in the bays and offshore can be rather frightening. On the other hand, there are no hurricanes this far south, so most boats wait out the hurricane season here, most in Golfito which is the most welcoming.
Be sure to always lock up your boat when leaving it to go ashore anywhere along the central american coast. You will find that otherwise a lot of stuff will go missing. I've heard that there has been a bit of violence lately, but in general theft is non-violent. There are some very accomplished pickpockets in central america, and the guys who might "help" you put your purchases and backpacks onto the overhead bus racks are too often very accomplished thieves, so don't let your possessions out of your hands. This hasn't changed in 20 years, so don't let it deter you from visiting, just be at least as careful as you would be in any city. The Pacific coast is beautiful, lovely diving, great shells, and mostly extremely lovely people.