As already mentioned in numerous comments, people do buy stuff on board airplanes and that's reason enough for airlines to keep doing it. The fact that even low-cost carriers who ruthlessly optimize their operation haven't ditched it is prima facieprima facie evidence that it must be profitable.
In fact, trying to add incidental revenue is a big trend across all modes of transportation. In the last decades, I have seen train stations turned into shopping malls, ads appearing on the back of airliners' seats and inside buses, booking sites pushing "partners" (say an hotel when booking a flight or a car rental when booking an hotel) increasingly aggressively, and several airports I use regularly being redesigned to force passengers to go through shops on the way to the gate or even when landing. From that perspective, in-flight shopping isn't a leftover of a bygone era (like free meals on short-haul flights) but fully in line with the way air transport is going.
As to why it works, I have seen a lot of patronizing speculation in other answers on why people might buy things (boredom, inability to compare prices, falling for aggressive marketing) but there are simpler explanations: Prices on high-margin items like watches can actually be quite good and there is a lot of added value in being able to buy travel items (battery charger, plug adapter, etc.) when you need them, even if it's at a premium. In some situations, it might even be possible to benefit from some tax exemptions (which is particularly relevant for highly taxed goods like cigarettes).
Besides, it's not even clear to me that higher margins are necessary to make this worthwhile for the airlines. How many people enter a shop and buy something after walking by? How does the cost of carrying a cart and a few minutes of the cabin crew's time compare to the costs of prime commercial real-estate and full-time staff to maintain a luxury store front?