In some ways, Heimdall's a walking plot device, able to get characters from Point A to Point B with his CGI sword-in-the-stone gizmo. In the myths, Heimdall was the silent guardian of Asgard, keeping perpetual watch it…as well as any villains that might come barreling towards it with pointy teeth bared.
The filmmakers parleyed that job into a viable set of character traits: loyal, duty-bound, soft-spoken and steadfast. He's got skills in the Comic Book-y Throwdown department—that sword of his can do some damage—but he can't top Thor or even the Warriors Three on that front.
No, his real power is being able to see the whole universe in an instant, and pick out the tiniest detail from amid that vast cauldron of Carl Sagan stardust.
That comes in handy when he needs to teleport his buddies into and out of monster-ridden ice balls…as do his sacred vows, his duties, and the fact that he takes them both extremely seriously.
Unfortunately for Thor, that doesn't always mean kow-towing to Thor's wishes. Heimdall does what Thor wants early on—by sending him and his buddies to Jotunheim—but makes it clear that he has his own reasons for wanting to, instead of just saluting to Little Prince Chestbeater and following orders.
HEIMDALL: You think you can deceive me.
LOKI: You must be mistaken...
THOR: Enough! Heimdall, may we pass?
HEIMDALL: Never has an enemy escaped my watch until this day. I want to know how it happened.
Also, check out his adamant refusal to open the Bifrost for Thor until he's sat on Earth for a good long time and thought about what he's done.
Luckily for Thor, that cuts both ways. Heimdall's loyalty and commitment to his guard duty doesn't preclude breaking the rules. Or rather, following the letter of the rules while blithely ignoring the spirit.
Nowhere is that more clear than when Loki's in charge and starts throwing his weight around:
HEIMDALL: Tell me, Loki, how did you lead the Jotuns into Asgard?
LOKI: Do you think the Bifrost is the only way in and out of this realm? There are passages between worlds to which even you, with all your gifts, are blind. But I have need of them no longer, now that I am king. And I say, for your act of treason, you are relieved of your duties as gatekeeper and no longer citizen of Asgard!
HEIMDALL: Then I need no longer obey you!
That puts him in the position of foil: a guy who's ultimately on Thor's side, but has his own way of doing things. He's going to help when it's expedient to do so, but he won't make it easy on Thor.
Thor's got to earn that magic trip over the rainbow, because this Gloomy Gus ain't gonna give it to him.