They could be rivals FOR something. Perhaps both trying to attain the same thing (or person)? Perhaps they simply can't stand to see the other one have something they don't?
It could be as simple as the family bond. Some siblings can be intense rivals and yet the bond of family overcomes all those differences when it matters.
Perhaps they are simply the sort who cannot express themselves in more suitable ways? While it's pretty typical of teenagers to pick on people they actually really like (because when we're teenagers, we're stupid ;P) that tends to disappear as people get older, but it doesn't mean it HAS to disappear.
Perhaps they both understand on some level that it's the competition and constant antagonism of their relationship that compels them to do better and achieve... whatever it is they're trying to achieve?
It might even be some sort of promise or guarantee to someone else entirely to protect each other? If they're siblings, maybe they promised their mother/father/someone who matters to them, that they'd always take care of each other? Even though they can't stand each other.
Hell, maybe they're like Dr Who and the Master. They can't stand each other, but in different situations, they would probably be the staunchest of allies.
Oh, a last second idea just before I hit Submit: could they have access to some secret stash (criminal gains? Inheritance? Something else entirely?) that each of them has half of the necessary code or information to access? Thus they have to protect the other constantly, even though they actively can't stand them?
[edit] Oh, I started to write all that before your post about them actively being friends... scratch half of those ideas then