I wonder if some degree might be self-medicating. I've seen it suggested developers have a higher-than-usual rate of ADHD and the like, and it wouldn't surprise me if that's true and caffeine use is an instinctual coping mechanism.
Sample size of one: I recently got diagnosed with ADHD in my 30s and put on amphetamines to medicate it.
I don't really drink coffee anymore.
I find that caffeine reduces my working memory. So sure it helps me stay focused on small repetitive tasks, but if I' trying to do something creative or open-ended, I keep my intake down. It's not a huge swing either way though - I rarely have more than three espressos in a day.
I had never really thought about that, but as a programmer myself, I'm a coffee (and tea) lover indeed!