The switch itself is fine. The problem is the silvered plastic piece that pushes the switch lever down. The green plastic "spring" has become deformed and refuses to return to the proper position. I detached it completely, cutting at both ends of the plastic "spring", then glued a piece of floppy plastic onto it because it only needs to be held above the switch lever. It doesn't need springness to return -- the switch's springiness is sufficient for that.
When reassembled the computer works perfectly, with the screen turning off when the computer is closed, and turning on again when the computer is opened.
The clear plastic is difficult to see in this photo. I should have used a more opaque strip. It is just a piece cut from a soft CD envelope -- the kind used in CD-books. You can see I cut it a tiny bit too long, but it works fine anyway.
I used contact glue because it sticks strongly to most plastics and has some flex and give. I didn't want the soft plastic strip to break away from the glue.