Mr. Rankeillor is a lawyer residing in Queensferry. Davie finds him when he gets back there in Chapter 28. Rankeillor explains to Davie what the situation is with his inheritance, so he's mainly a plot device to wrap up those loose ends with Ebenezer Balfour.
Still, Stevenson tries to give Rankeillor a bit of flavor by pointing out that, in addition to being a kind, smart guy, he's also an incredible know-it-all. He values learning highly (as would anyone who has to go to school as long as a lawyer), and he's constantly quoting Latin to sound more refined. Like Mr. Henderland's snuff addiction, this apparently unattractive characteristic actually makes Rankeillor more endearing. He's a great guy all around and very sympathetic to Davie.
As a man of the law, Rankeillor feels guilty about meeting Alan, the outlaw. He gets around this by addressing Alan as "Mr. Thomson," so that he can pretend he doesn't know Alan's true identity.