Been to both, not with kids.
I would say both are doable with kids. Both have fabulous wildlife (Costa Rica is more birds, turtles, dolphins, tropical fish etc whereas Sri Lanka has some safari type animals such as elephants). Lots of monkeys in both. Costa Rica doesn't have much culture to speak of whereas Sri Lanka has interesting temples and ruins and so on.
The people in Sri Lanka are absolutely lovely. You may find people wanting to take selfies with you in certain places.
If you like spicy food, the food in Sri Lanka is absolutely amazing.
I don't know, putting it into words like this it looks like Sri Lanka is coming out on top but I thought Costa Rica was amazing and we had probably our best holiday there. The national parks and the pony trekking and seeing turtles hatch on the beach.
Costa Rica is probably a bit safer. You'll find it easier to get around if you hire a 4x4 and drive around yourselves, although we took buses to get from the Caribbean side to the Pacific side. In Sri Lanka you can do some travelling around by train (but not all). If you stay in places with great customer ratings you can ask owners of B&Bs to find you a driver to take you wherever you want to go next without too much difficulty.
Costa Rica is much more westernised, and I think more expensive than Sri Lanka because a lot of Americans have second homes there. The hospitals are good though if you have an emergency.
My boss just went to Costa Rica in August with his three kids and had a great time. (He has also travelled with them to Thailand and Brazil.)
Sorry this probably isn't much help but they are both great places for a holiday.