So this is a custom that is currently trending in a few places, the idea is that you pay for an extra coffee and then the barista can give a coffee out later to someone who needs it. It's a bit of sales-boosting feel-good and it's spread to things other than coffee.
The NYT article claims it to be a post-WWII hardship tradition, I've seen it given as a post-WWI hardship tradition as well. It seems a bit tidy to me, to have a nice historical story to go behind a modern trend, and coffee culture history in Italy usually runs a bit older than that. Any insight? (Italian sources are welcome.)
I believe both hypotheses to be wrong.
The practice, which is limited to the Naples area (e.g. you won't find it in Rome), might actually have to do with the sanctions imposed by the League of Nations in 1936. After the Italian conquest of Ethiopia, 'real' coffee - only a fraction of which was imported from that colony - had become a rarity and people resorted to drink chicory juice as a substitute; not exactly the best-tasting beverage around. Such a situation persisted until the immediate postwar, so I wouldn't be surprised if people started offering each ofter a cuppa coffee once there was no more lack of it...
...and that such a tradition had stuck for the years to come.
None of my sources seem to be aware of the phenomenon, though, so my guess is as good as yours.