A lot of code today is indeed poorly optimized as one is preferring productivity over performance. It is a valid choice given that hardware today is so insanely fast that you can handle even very inefficient code.
Yet highly tuned efficient code is still written where it really matters. 3D game engines, massive weather simulations etc have to be written in an efficient manner because what these systems try to do is extremely demanding even on todays high performance hardware.
However, I think you have some misconceptions about the nature of x86 processor in relation to Arm and RISC-V processors. I see many who seem to think that the instruction-set of x86 is somehow very advanced or high performance because it is extremely complex.
No, it isn't. The complexity of x86 isn't intentional and necessary complexity. It is what we could call accidental complexity. It is complex because of a combination of poor understanding of hardware when designed plus realities of hardware being very different back when these instruction sets got made.
When x86 chips first got made, there was no difference in speed between memory and CPU. Fetching instructions was not a bottleneck. However memory was very expensive. Hence designing an instruction-set which allowed you to reduce the memory used made a lot of sense. That is how we got CISC design.
It was however not the only possible way of achieving lower memory use. RISC processors achieved lower memory use by using compressed instructions and using large number of registers. That was simply not an idea understood or realized back when x86 got designed.
In short there is nothing good about x86 instruction-set for really anything. It is really just a bad outdated design. Intel and AMD make it work by spending lots of money to design solutions working around the inherent flaws of the x86 instruction-set.