Heimdall is the all-seeing and all-knowing Asgardian warrior-god and the guardian of the rainbow bridge, Bifrost, watching for any attacks on Asgard.
Heimdall the Gatekeeper is a servant of Odin All-Father and ally of Thor Odinson. He was the guardian of Asgard, standing on the rainbow bifrost bridge and denying access to any unauthorised beings. When the Frost Giants slipped past him (with the assistance of Loki Laufeyson, though no-one knew that) Heimdall was determined to discover how the enemies slipped past his all-seeing gaze, and allowed Loki, Thor, his friend Sif and The Warriors Three to travel to Jotunheim and confront the Frost Giants, against Odin's orders. This led to Thor's banishment.
The Gatekeeper reappeared when Odin fell ill and Loki became king; despite technically being the servant of Loki, Heimdall remained loyal to the All-Father, and allowed the Warriors Three and Sif to travel to Earth and help Thor combat the Destroyer (all this against Loki's orders). Loki used the Casket of Ancient Winters to freeze Heimdall solid for his treachery.
When Thor and the Warriors asked Heimdall to open the bifrost bridge so they could travel to Asgard and defeat Loki, the Gatekeeper displayed a huge amount of effort and broke out of his ice casing, opening the bridge. He then collapsed. Thor send the Warriors and Sif to assist Heimdall while Thor himself dealt with Loki. Heimdall was later seen on the broken bifrost bridge, telling Thor that Earth may not be lost to them and that Jane is searching for a way back.