It comes down to two words: Free Stuff. Costa Rica does not have the Free Stuff Cornucopia that the US has thanks to the American Tax Drone. Work harder, more dependents are on the way.
Costa Rica is a very rich country and Honduras is very poor. The citizens of Costa Rica have known all their lives that they could be over run by their poor neighbors. Hence they maintain their border.
As to free stuff, I do not know their social safety net policy, but I do know that if you can’t get in, the policy will not apply to you.
My knowledge of immigration policies is limited, I once considered moving there, as the cost of living is lower than the US and the country is beautiful. (Many from the US do make Costa Rica their home.)
Here is a link that shows that they do have a merit system involving self support: https://www.costaricaimmigration.com/immigration.htm