I’ve heard that the clams which don’t open up are dead and therefore not fresh. Which implies that the clams are still alive when they open up in response to the heat. Why they do this, I have no idea.
Also, normally you have to leave clams in water overnight to make them get rid of sand. You can’t do that with a dead clam, so I’d guess the ones that don’t open contain a lot of sand.
I used to work a raw bar during the college summers. In my experience, clams that don’t open are either dead and rotten, or they just haven’t been cooked long enough. If you take a knife and pop open a cooked clam that hasn’t opened, you’ll see either something that looks like mud–bad clam, or an undercooked clam; cook it some more–it’s still good.
Not all clams are created equal and they don’t open at the same rate; bigger clams usually take longer to open.
The key is not to overcook them, so I always removed them as they popped open when I prepared an order, ensuring all the clams were evenly cooked.