There is a small group of phrases that act as warnings. "No offence, but..." is one of them. "I don't want to be rude, but..." and "With respect..." are others. Their purpose is to prepare the listener, in the way a nurse says "you may feel a little pressure" before the injection.
Linguists call these phrases disclaimers. In theory, a disclaimer protects the speaker. If I say "no offence" first, then I can claim that any offence was unintended. The phrase works like an advance apology, purchased before the crime.
The trouble is that listeners do not behave according to theory. When we hear "no offence, but...", we do not relax. We tighten our shoulders and wait. The phrase has not made the sentence gentler; it has only announced that the next sentence is going to be a problem.
The second effect is less obvious. A disclaimer moves responsibility from the speaker to the listener. If you are offended, the implication is that you are being oversensitive, because you were warned. Seen this way, "no offence" is not an apology at all. It is a small act of defensive punctuation.
What is the alternative? Honesty is sometimes unpleasant, and no phrase can change that. But there is a difference between a hard truth and a careless one. Instead of preparing the listener to be hurt, we can explain why we are saying it: "I think this plan will fail, and I would like to help." This is longer than "no offence, but...", and it is much harder to hear as an insult.
The best disclaimer is a reason. The rest is just warm-up.
Fiction note: All people, places and events in this text are fictional.