Electricity can instantly kill you or start a fire, which could kill you and your neighbors. Look at what just happened in Boulder. Fire is dangerous, especially when combined with high winds. I personally saw that play out twice while living in Boston, one of which was determined to have been caused by sparks from unpermitted welding, the other by improper disposal of smoldering construction debris. Both small starts whipped up by winds, both times multiple people died.
The phrase I’ve heard is “regulations are written in blood.”
But sometimes you are correct. Like in writing where it’s best to know the rules of grammar before you start breaking them, it’s best to know why the building codes exist before you break them as a DIYer.