Based on the abdomen shape, I'd be inclined to think it was a Gall crab. They really will not damage corals. And I think they're pretty cool.
If you found the crab literally inside the coral, it is probably a female. They're pretty much limited to filter feeding and snacking on mucus and algae near the opening. Males are a lot more "free roaming" but have similar diets.
Personally, I'd put it back, assuming someone can give a definitive ID. Could you put it in a container in the water? It's a little hard to tell when it's out of water.