Only in a hello world application. Every professional editor like GIMP has tons of tiny widgets. And redrawing one tiny widget on mouse over is faster than running the render function.
Also, you are assuming that running render function costs nothing while in real-world apps there will be array iteration (for example, to display a sum and average of values from a 100K element array), calling helper functions, generating SVG for a 10K points graph, etc.
Yes, writing good code is harder than bad code, especially for a LLM.
You say I'm assuming that the render function costs nothing. I thought it was clear that I was not assuming that; what I said in the comment that you're responding to is, "The amount of per-drawable work has to be almost three orders of magnitude larger before the per-pixel work isn't the dominant factor." But you may have responded before I added that; I forget if I added it in later. Here by "drawable" I mean talking about things like letters, not widgets that have their own render functions. Widgets that have their own render functions can take more than four orders of magnitude more time than the per-pixel work before the per-widget work becomes the dominant factor.
It's true, as you say, that people are capable of using up that margin by doing things like reading from a file, because writing good code is harder than writing bad code. But that's not really a question of immediate-mode vs. retained-mode. You can write bad code with retained-mode GUI libraries, too. In fact, my experience is that it's much harder to write good code with retained-mode GUI libraries.
As for layout calculations, the layout engine I elicited from Opus 5.5 for http://canonical.org/~kragen/sw/megilloom-sandbox lays out 60,000 lines of text per second, in JavaScript, and it supports table layout. (It caches the layout calculations so that it can remain responsive up to hundreds of thousands of lines.)
Some IMGUI libraries are capable of providing a dirty flag and damage rectangles without requiring every application to duplicate the error-prone cache-invalidation logic to do that. As Raph points out in this post, they're not a panacea. But they're not as bad as you are naïvely assuming them to be.
Because writing good code is harder than bad code.
If you're concerned about efficiency, GPU support is very important. But IMGUI is not the efficiency enemy you think it is; while IMGUI libraries do need to traverse the hierarchy of visible objects on every mouse movement, there are generally only a few dozen rectangles and a few thousand letters and other graphical objects visible, so the work involved in traversing them is generally very small amount compared to copying a few million pixels into the framebuffer.
As an example, I currently have a browser viewing HN and an Emacs window open, and they total about 3000 characters, a couple dozen icons, and another dozen or so roundrects. But my screen is 2 million pixels. So the amount of per-drawable work has to be almost three orders of magnitude larger before the per-pixel work isn't the dominant factor.
IMGUI libraries do have to do a bit more work to avoid redrawing all those pixels on every mouse movement, but many popular IMGUI libraries, such as React, do in fact do that work. It's a somewhat less simple job than for retained-mode GUI libraries like Qt (or the browser DOM), but the added complexity in the IMGUI library often pays off in simpler and more reliable apps.