Legal, schmegal

The intersection of photography and the law has always interested me. I just got the strangest note from a museum, reading me the riot act over a few photos I posted online that I took of their collection. I explained I wasn't selling my photos on my personal site and they eventually called off the hounds, but I'm still taken aback whenever I go somewhere with fine print on the tickets that lets you know commercial photography is a strict no-no.

Any lawyers in the audience care to tell me why these things are enforceable? I can see how taking a photo of a painting, then making lots of prints and selling it would be harming the museum (that might have prints for sale in the gift shop). But taking a photograph of an object within the museum, or a strange view of a sculpture there, how does that harm the museum aside from them merely wanting a financial cut of the action? Is it legal for them to demand you can't sell a photo if you are at a private, non-profit museum? How about at a public one?