Luffy's hat is his treasure. When he was just a kid, Captain Red Haired Shanks and his pirate crew would stop in Luffy's home town from time to time, and Shanks was Luffy's hero. The straw hat originally belonged to Shanks. What happened was that Luffy found a fruit from Shanks' pirate ship and ate it. It happened to be a "cursed fruit" that would change him. He was given the ability to stretch like rubber, but he lost the ability to swim. Ever. Luffy+GumGumFruit=Swimlessness. So this mountain bandit shows up and eventually takes Luffy out to sea in a little boat. He throws Luffy out in the water, and Luffy can't swim. But then a huge sea monster comes out and totally eats the boat the mountain bandit's on and then he goes after Luffy.
Guess who pops outta no where and saves him? Shanks! You're right! lol So Shanks saves him, and Luffy's bawling. A conversation somewhat like this one ensues:
Shanks: What's wrong! The sea serpent's gone!
Luffy: Yeah, I know... *bawling* but Shanks!... YOUR AAAARRRM!!!!
Yeah, so the serpent totally ate Shanks' arm.
Then, as Shanks decides to leave Luffy's town and ne'er return, Luffy says that one day he's going to be a great pirate and go on his own adventures. Shanks mocks him. Luffy then says that he's gonna be King of the Pirates and find One Piece and have a crew better than the one Shanks has. So Shanks gives his hat to Luffy and tells him that it means a lot to him. He tells him that he must promise to give it back when he's become a great pirate.
So the hat is Luffy's treasure. And he fully intends to keep his promise to Shanks.