If we didn't have building codes and inspectors, think how difficult it would be to buy a house. You'd have to have an expert go through the house and inspect basic things, such as spacing between studs, size of headers, support of headers, attachment of the roof to the sides of the house, engineering analysis for loads and earthquake resistance, etc. etc. Every buyer of every house would have to do those things.
When you have building codes, you can check when the house was built, or was involved in a major remodel, and you'll know the status of the house - if they followed code.
Code also protects the occupants. I read somewhere that cities are trying to find additional missions for firefighters because improvements in the building codes, and appliance safety, have greatly reduced the occurrences of fires. So the firefighters have less to do in urban areas.
Building codes and the inspectors are your friends. It's sometime a pain to deal with the inspections (scheduling, disagreements with the inspector, etc.) but building codes save lives and guarantee the next owner that things were done correctly.
Mike