There were three players in the hand including myself. I had the button. person to my left makes a bet, the second player goes all in, I go all in and flip my cards accidentally before the player to my left calls the all in. I was upset for showing my hand and stood up with the cards in my hand and stepped back off the table for less than a second before another player in the hand yelled saying that my hand is dead for moving my cards off the table. I flopped a straight and had both of them beat. they run it out and said my hand is dead completely even though I won the hand, the second winning hand got all the money. Is this a rule? is it fair?
An all-in hand, and especially one that was exposed so all players knew what it was, cannot be declared dead.
If you were not all-in many places may rule you dead for even getting out of your seat, some will not of course, everywhere has different rules on dead hands. Basically if you're all-in, or not, always protect your hand.
In your situation no way is your hand dead. Ludicrous ruling. You could be given a penalty, but a dead hand is a stupid ruling here.
From what you describe your hand should usually not be ruled dead. But there are problems with the way you handled your cards, that yes can open that can of worms that can leave a player without a pot because the hand is dead.
A player should never pick up their cards off the table. There is no upside to it for the player or the player's opponents in the game. All that can happen is that cards get exposed (like you found out) disrupting the game, and cheats get a chance at misdirection. It is bad poker manners and yes it is against the rules for those reasons listed.
It does however happen all the time, and rarely does it result in a dead hand. It is not really clear rather a floor person came and ruled the hand dead or you where playing in a more private game. If it was a private game and the players decided the hand was dead, yeah I would not go back because it looks to me they were taking a little angle themselves by killing your hand. If it was a public cardroom, and this was kind of a one off ruling, it is not likely I would rule the hand dead, but some floor people may be inclined to and perfectly within the scope of their duties to do so, although it could rightly be considered somewhat petty. If this was something I was called on to rule more then a couple or a few times with a player I might very well be inclined to kill the hand.
When you play poker look at your hole cards like a twenty one dealer, keeping them secure from other players. Then cap them and leave them on the table. To do otherwise weakens the security of the game your playing in a bit, and as you discovered, can lead to some pretty expensive consequences when someone with authority wants to be a stickler for the rules for whatever reason, malicious or not.