You can get penalties for all kinds of things. Drafting a team car comes to mind. Those get negatice points. That is different from fouls during the sprint itself. In that case you get relagated to the back of the group you were in.
The reason for negative points for midrace fouls is that they give the rider a benefit, they often do not get caught and the benefit may even roll over to the next stage.(E.g. legs not as tired).
BTW there are also time penalties for the same infractions so they cost you in both time and points. There have been cases where riders who were close to the time cutoff who received a time penalty, which does count for time on the stage, which put them past the cut off and out of the Tour.