Yes, it is important and should be done to understand what google thinks about your website and also understand the issues, errors, improvement in website and make suggested changes. It is completely safe to add google code on website. It won't harm your website in any ways.