I don't think it's been explained, exactly.
They didn't seem to know each other when they met in the 20th century. Although they certainly didn't get along the first time they encountered each other, after Bart's visit to the Legion while they were staying at S.T.A.R. Labs and their, uh, cooperation to make up for almost destroying the place, it seemed as though Brainy and Bart were getting along. After all, Brainy was the one who summoned Bart during the C.O.M.P.U.T.O. attack (despite the protests of the other Legionnaires!) and Brainy had given Bart the telepathic earplug so they could keep in touch. I had also thought it was at least implied that Brainy was the one vote to let Bart into the Legion.
That bothered me about their interaction in the Titans/Legion crossover... Brainy seemed uncharacteristically hostile to Bart, whereas before it seemed as though they were somewhat friends (moreso than Bart and the rest of the Legion excepting Jenni, at least.) It was... rather like the writer had only read the encounter in Impulse, and wasn't aware that they'd "made up" somewhat.
I really like the idea of Bart and Brainy being unlikely friends. I think it's too bad that the idea wasn't explored more (with the VR link or even just with their "in-panel" interactions.)
Edit: Sorry that the post is a little bit rambly and not much help... I just really thought the idea of a Brainy and Bart friendship was cool, and was very disappointed that it kind of got pushed aside for more predictable animosity...
