Answer for What is the purpose of building permits and codes?

The purpose behind building codes is to give reasonable assurance that a building is safe from structural failure, fire hazards from electrical and heating systems, electrical shock, and health risks. The building permits provide a permanent record of the work performed and inspections conducted on the project.
 
It is important to meet building code standards to ensure safety for current and future owners. Rough-in inspections take place during a project where inspectors inspect work that has been started but not completed, referring to wiring, plumbing or line fixtures that are not hooked up or attached yet. Codes are not only written for safety reasons, but also for environmental and energy saving considerations.
 
Source: https://www.scoutservices.com/permitting-faqs