It’s an unwritten rule, of which there are many in cycling. It has nothing to do with passing your opponents per se, but rather taking advantage of a mechanical problem that the ‘yellow jersey’ (race leader) is having. That is seen as un-sporting and disrespectful.