Earning a living as an artist is tough. Most won't get their work seen in a gallery, so they turn to commercial art or graphic design. Now they learn to create art for a client that fits a brief. They do this every day for years until they lose the ability to make art for themselves. I know this happens, because it happened to me.
Learning to code was the best career decision I ever made. I now make significantly more money than I did before, which enables me to fund my own art projects on the side. I'm learning to get back in touch with why I wanted to make art in the first place. Like it or not, we all need to earn a living. In my opinion, doing so in an art-adjacent field is not somehow morally better than doing so in tech.
You don't only "lose" artists to commercial art. Many choose it intentionally, because it can be its own reward. Whether it's fine artists who do comics, storyboards and magazine illustration (e.g. Bill Sienkiewicz, Kent Williams, Geof Darrow) or classic illustrators like Syd Mead, Bob Peak, Fuchs Norman Rockwell and sleeve designers like Saul Bass, Hugh Syme or Storm Thorgerson on down to weird mutant hybrids like the Emigre font house or Vaughn Olivers' v23 or the Bill Smith Studio....the line between "artist" and "commercial artist" is a blurry one.
I've moonlit as a commissioned painter and illustrator (whose work often enough ends up licensed for commercial purposes, usually book cover or musician-packaging) and I find zero issue bouncing between the two spaces. I know that is not necessarily for everyone, but its also not a small slice of folks either.
I don't know I just feel like the categorization is a bit unfair that doing something you love in a commercial setting will strip you of your creativity. I think to some extent work as whole through pure exhaustion does that but that's why I'm glad that I get the measly reward of doing something adjacent to what I enjoy. I'm sure I'd feel differently if tech salaries were lower but if they were identical would you really prefer writing enterprise software all day over doing commercial art?
I remember a commercial for Mucinex (cough medicine) where anthropomorphic boogers get their house wrecked by a tornado courtesy of Mucinex. Somewhere in the chaos, a painting of the Mona Lisa as an anthropomorphic booger goes by. I often wonder what was going through the artist's mind while they were crafting that little detail.
I had to change into software because I couldn't get fulltime work anymore and needed the benefits (I'd been coding for fun since high school - started with Flash). It was all gig jobs. Plus I make substantially more coding because "I don't get the pleasure of having the dream job of making art for video games".