Because I bet you all do it in your daily life. Boss annoys you? Throw an insult.
I think this raises a relevant issue. If I made the remarks Boris did at work I would be investigated by HR; Boris was at also at work, he is an MP if he speaks or writes on any subject while an MP, he is doing so as a publicly appointed officer. He is not, officially anyway, employed as a comedian. This means that his comments were not just rude they were in breach of the MP's code of conduct, his contract and company policy as it were. In addition he is an MP for an area with a significant Muslim community, he is supposed to support that community and represent them, ridiculing them goes against that. So he also breached his public duty/contract to his constituents.
He does not have freedom of speech that is unfettered, if he wants that he needs to resign and, from comments on here, pursue a possible future as a low-level comedian. He was additionally in breach of contract because he was not entitled to take on paid work until he had been out of his ministerial job for three months and also needed clearance after that.
When he wrote that article he was at 'work'. So he breached his duty as an MP representing his constituency, breached the Code of Conduct, and breached rules on taking on outside paid work. I know what would've happened to me if I did that at work and it would not have been good.