Several basic reasons.
It is manufactured, and created, there. This allowed them to genuinely take advantage of associating Irn Bru with Scottish pride, much like whisky. Scotland born, Scotland made, Scotland pride.
Furthermore, they have long been known for creative, sometimes problematic, advertising which as the adage says "there is no bad publicity". From their "...even though I was a man" transgender commercial (I'm mobile so no link, sorry) to their "cheer up goth" campaign, they were always very tongue in cheek and edgy.
This combination of instilling pride, an earlier foothold in the market and continual creative marketing lead to them holding their own.
It should be noted though that they are equal to Coke in sales at this point and have lost some home footing.