Sea cucumbers are delicate animals and do not have many ways of protecting themselves from predators. Some of them can produce sticky threads which are discharged to ensnare their predators.
Another way of defense, adopted by sea cucumbers is self mutilation. They can violently contract the muscles in their bodies and expel some of their internal organs out of the body via the anus. These are meant to distract predators and they also become the food of the predators. The predators then do not pursue the sea cucumbers and it gives them time to escape. The internal organs that have been discharged grow back quickly and this process causes no permanent harm to the sea cucumbers.
Say a sea cucumber was being attached by a predator one way for them to escape from their predator without being harmed is for them to expel their stomach and gonads from their body to distract the predator. The predator will start eating there guts while they escape. The sea cucumbers body will quickly replace whatever tissue or organs were lost. So the advantage to Sea cucumbers for expelling their guts is that it provides a way for Sea cucumbers to defend themselves when being threatened.