Pencils here are a bit like grains. The market works for them because they fall into such a niche that economic "laws" works there.
But it's a fallacy to apply it elsewhere and there are millions of examples where the free market failed to optimize a product.
I don't agree. Loads of things are like this. Cars, microchips, hard drive storage, monitors, TVs, laptops. All either much better than they used to be, or much cheaper, or both.