Rainforests, and forests in general, are abundant in Costa Rica. National parks offer many trails you can hike on, and lots of people organize weekend trips to mountains and places around their home towns.
But, the rainforest can be just as dangerous as it is pretty. Every year, people get lost and accidents happen at these visited sites. Things people wouldn't normally do while taking a trip back home, all of a sudden seem like a great idea, which gets them in trouble.
Treat the forests and parks as you would treat any tourist or trip destination where you're from. Use common sense: don't do stuff you wouldn't do back home. If back home it's dangerous, here it's even more dangerous since you're not familiar with your surroundings.
Always let someone know where you're heading to and when you're expected to return, even if it's just the front desk at your hotel. Or message someone back home. If you have internet on your cell phone , you're only a few keystrokes away from friends and family. So there's really no reason to be heading out without at least one person knowing what your plan is.
Trails are clearly marked in parks and tourist destinations. Stay on them. Don't just wander off to see something that might look interesting in the distance, or try to cut the distance by going straight through.
And unless you really know what you're doing, don't just head into a mountain or forest where there's no marked trails. Use the parks and recreational spaces, they've already taken care of making your hike as safe as possible. No reason to go looking for trouble elsewhere.
Forests are dense, and the trees all look the same after a while. What seems like a beaten trail, can't be found a few minutes later. Dense ground cover can hide holes, cracks, and steps. And the abundant rain and water you usually find here can turn any slope into an accident waiting to happen.
Not to mention that in the forests, cliffs and river gorges are abundant, and don't always seem so clear, especially in dim light or fog.
Your phone's GPS can easily go haywire under the dense canopy, and of course there's no guarantee that you're going to get a cell signal somewhere in the middle of a mountain.
All the above, and more, are reasons why you shouldn't go wandering in the forests here. Or anywhere else you're not familiar with, for that matter. If that's not enough to convince you, consider that even Discovery Channel's Bear Gryllis the indestructible explorer, had a very hard time coping through his improvised rainforest quest in Costa Rica.
Enjoy the country and the sights, but know the limits, and stay safe.