Safety is probably the original reason for having building codes, however today the very significant majority of these rules (measured by both quantity and design time required for their impementation) has nothing to do with safety. Codes dictate building masses and building areas, building lines, requirements for parking, facade design, choise of materials, form of the roof, floor heights etc. etc. Some of those don't cause very much damage since they are useful and most architects would implement them anyways. As to the others...