here's the rules as Set Down by the California
Gaming Commission - I don't think its any different in most other places, but I'm not 100% on that.
It IS illegal to show one or both hole cards to any player in the hand, and the dealer/floorman may decide it is an automatic muck.
The exception to this rule is if you are either heads-up OR the only hand which isn't all-in already.
It comes down to collusion: showing your cards if anyone else is left to act gives information to some players, but not necessarily all (so you're cheating by selecting the information given). On the same vein, the information may be more helpful to some players than others, and hence affects the betting unfairly. A great example: UTG holds AK and flops a straight, and bets. MP shows KK, and raises. Button (with T9) just lost 2 of his outs for his open-end, and his 2nd pair chance, and folds. The information from the exposed cards affected the betting, and could be considered collusion.
Also - and I see this one all the time - it is illegal to ASK what an opponent has except heads-up or last all-in, for the same reason - collusion. I see this ALL the time, though.