It is heresy to say, but of course writing programs primarily as simple text files is ridiculous. It’s also ridiculous that we write web pages in HTML etc rather than using elegant WYSIWYG editors, and that we use LaTeX for designing visual artefacts.
It’s probably possible to explain “why” we got here, but not “why” it’s a good idea, because it isn’t.
I put it down to culture. Programmers are strongly opinionated and resistant to change (eg blub). We’re historically been selected from a narrow and strange demographic. Which is why few people agree with what seems obvious to an outsider, and why we don’t fix it.
Imagine if engineers built bridges or engines or satellites by writing XML rather than using CAD tools and modelling suites.
I seem to recall nice ideas around Smalltalk’s editor. It should be possibly to have a hybrid approach that can gradually transform programming from text editor into a mixture of maths and high level engineering design.