Optimized code takes longer to write and is often more complex and less readable and less maintainable. Since software engineer salaries costs are higher than hardware costs it would take way longer and cost more to optimize all code.
When you're writing code sometimes you need to refactor, requirements change etc.
You may focus on optimizing code for saving 3 nanoseconds on code that doesn't run that often.
Optimization is important, and can save money on hardware resources, but focusing on the wrong things to optimize can be costly and make the application more difficult to maintain.
Once you identify the bottlenecks of the application you can focus on optimizing these.
Obviously that doesn't mean you should throw away resources, so it's always a good idea to use static analysis in combination with code reviews to avoid unnecessary use of resources, like repeatedly doing a costly operation in a loop that always yields the same result (it can be done before the loop starts, or you can memoize/cache the result to reuse it), caching network/database requests that are expected to return the same data, use a connection pool for expensive resources like database connections...
But more advanced optimization should be reserved for bottlenecks.