This topic comes up every few months. We need a sticky.
Before MacGregor built the X and M models - powersailors - a large number of buyers of their sailboats were first time, inexperienced sailors. MacGregor put enough styrofoam into them that they would float even if completely flooded. This was, imo, a marketing tool that helped reassure inexperienced buyers.
As you probably know, the great majority of sailboats don't have flotation and if flooded, would head for the bottom faster than a nuclear submarine. Well, maybe not that fast.
In my opinion, the danger of sinking is so small that if you have need of the space occupied by the styrofoam and don't feel uncomfortable with that small safety factor missing, then go ahead and take it out.
I don't yet have need of that space on my boat but if I did, I would have no qualms about removing the foam.
Keep in mind that if you want to resell the boat, the presence of the foam might be a good sales factor.