Building codes represent nothing but the personal preferences of the people who write them, based on subjective values rather than objective principles. There is no one right answer, it's all about trade-offs.
For example, suppose the building code in your climate mandates R20 for wall insulation. This number is not based on any objective scientific principle. Generally, the more you spend now on insulation and air-sealing, the lower your fuel bills will be later. But allocating more upfront for insulation means sacrificing resources that could have been used elsewhere. There are no free lunches, only trade-offs. Ultimately, the decision comes down to the values of the person making it.
You say, "But R20 is reasonable." No it isn't. Reasonable means based on reason, and there is no reason why R20 would be the ideal standard for millions of different homeowners, all with unique preferences and circumstances. Homeowners who would naturally choose R20 on their own are no better off for being forced to comply. Meanwhile, those who would prefer a different approach are made worse off. What justifies the state overriding their choices? The argument that it’s for the "common good" doesn't work when the primary beneficiaries of such mandates are insulation manufacturers—not homeowners.
Although this example focuses on insulation, the same reasoning applies to every aspect of home construction. Since building codes make no homeowners better off, and make millions of homeowners worse off, they should be abolished.