Eating raw or undercooked crabs can cause illness if the crabs that were undercooked or raw had some parasites or bacteria in them.
Raw or undercooked crabs can sometimes contain different pathogens, including bacteria (e.g.Vibrio cholerae and Vibrio parahaemolyticus) and parasites (e.g. Paragonimus westermani, also known as lung fluke.
This can make you sick and you could potentially die so it's best to make sure you fully cook the crabs before eating them to avoid possible illness.
It's rare that you would get sick from eating undercooked crabs as some of those parasites and bacteria should have been killed off by the cooking process but there could still be some bacteria and parasites in the crabs.
If your bodies immune system is weakened then it could affect you more.