The straw hat Luffy wears actually belongs to the pirate Red Hair Shanks. It's Luffy's greatest treasure.
The Straw Hat is a special item from the manga/anime series One Piece that was written by Eiichiro Oda. The series first began serialization in in Weekly Shōnen Jump on August 4, 1997. It first appeared in One Piece Volume 1 CH. 1 "Romance Dawn", and the anime appearance was in One Piece - Episode 11 "I’m Luffy! The Man Who’s Gonna Be King of the Pirates!".
The Straw Hat that Monkey D. Luffy protects so strongly was first thought to of been originally the property of Red-Haired Shanks, but later chapters suggested that the hat once belongs to Gold Roger.
Shanks, captain of the Red Haired Pirates, was the first person in the series to be shown wearing the straw hat. He always told Luffy that the hat was his treasure that he'd never part with. However, after Luffy used the same words Shanks' his old captain, Gold Roger, did, did. He gave Luffy the hat. It became a symbol of the promise between them that Luffy would return it to him one day after he became the great pirate he swore to become. Those who meet Luffy that had once met Shanks often recognize it immediately.
Luffy was given the straw hat by Red-Hair Shanks. Not as a gift, but for safe keeping. He promised to return it to Shanks after becoming a great pirate. Luffy has always been extremely protective of his hat and rarely lets anyone else so much as touch it. He's trusted it with very few members of his own crew. The only time he's ever lost it in battle was first against Crocodile, then went he catatonic at Marineford after witnessing Ace's death.
When Luffy went to train in the use of haki with Silvers Rayleigh, he left the hat on the island in the one safe place for two years. He only put it back one when his training was complete and he was heading back out on his adventure.
On a number of occasions Luffy has left his hat with Nami, for safe keeping while he went into battle. She's also the person who repairs any damage. The manga canon events are when Luffy went to fight Arlong, in the Mock Town bar brawl with Bellamy, and the fight with Enel. When Luffy was given a Vivre Card from Ace, Luffy asked Nami to sew it into the brim of his hat so he wouldn't lose it. After Nami started to join into the fights a strap was added, but is seems to appear and disappear. Nami is seen often wearing the straw hat during some special splash pages to chapters, (examples Vol. 40 Ch..379 & Vol. 61 Ch. 595). This can also be seen in the seventh opening to the anime, "Crazy Rainbowstar" by T&T.
Luffy has also left the hat with Vivi when on Little Garden. During the Davy Back Fight, Usopp wore the straw hat since Luffy was currently wearing a giant afro, and Usopp was serving as Luffy's second.
Gold Roger, the captain of the Roger Pirates and the original King of the Pirates, has been revealed to be the possibly original owner of the straw hat. He was shown to be wearing it as a much younger man when he met his first-mate Silver's Rayleigh.