
They look like they're great friends.
In Thor, Heimdall has a reason to be suspicious of Loki beyond "he's mischievous and I don't like him". The Frost Giants enter Asgard unseen, and, over the course of the film, Heimdall realizes who possesses the power to conceal them. After Loki declares Heimdall a traitor and no longer a citizen, Heimdall strikes to kill, though he is prevented by Loki freezing him with the Casket's power. I don't blame him. He thinks Loki's aiding Asgard's greatest enemy in conquering Asgard and means to usurp the throne. This might be compounded by Loki being a Frost Giant. If we assume that Heimdall was aware of this fact, we can assume that there's an element of mistrust that comes with Loki being what he is because of Asgard's racism.
So, given the animosity in Thor, how do we end up here in Ragnarok?

Heimdall: Welcome home. I saw you coming.
Loki proves himself more willing to protect Asgard than Odin or even Thor. And that must have been a true shock to Heimdall. He’s always supported and believed in Thor, to the point that he’s betrayed Odin. And then Thor at the end of TDW just leaves. He just leaves even though the city is still half-destroyed after an attack and Frigga’s died. And who’s there to get things back on track instead? The Frost Giant that betrayed everyone. That committed horrific crimes.
Loki declares Heimdall a traitor (again), but... it's weird. Heimdall's just hanging out in Asgard's wilderness. He's not making an effort to expose Loki. He didn't even bother to take his sword when he went on the run. Loki doesn't appear to be that concerned about Heimdall's presence on Asgard. I take this to mean that Heimdall's doing what he does best: watching, ready to take action if he feels Loki's no longer acting in Asgard's best interest. But Loki continues to be a decent king for Asgard, and Heimdall respects that.
Finally, there's Heimdall's line above, which I find very, very interesting. Heimdall states that he saw Loki coming, and Loki responds, “Of course you did.” Now, where Heimdall’s sight concerns Loki, we know there’s no “of course” about it. Loki can shield himself and others from Heimdall. So, Loki let Heimdall see he was coming. He let him know help was on the way, despite the fact that a much more dramatic entrance would have been a complete surprise.
In summary: Loki in Thor unintentionally convinces Heimdall he’s betrayed Asgard and attempting to usurp the throne, and then, over the course of the next movies is like, “No, I’m loyal to Asgard, you fool,” without saying a damn word. And Heimdall gets the message, so he welcomes Loki home despite everything Loki's done. I adore that relationship development, and I'm willing to bet it's entirely accidental and I'm just extrapolating from a series of ill-considered (often implied) interactions.
(Compiled from Tumblr)