the code block is added to the template page because you have added a quick cart to the template.
so if you remove that code, the quick cart may not work correctly.
leaving that code in the head is causing security assist not to be able to place the restrict access code correctly, it will also cause errors on trying to redirect in some cases.
the <!-- TemplateInfo codeOutsideHTMLIsLocked="true" --> line should be placed just after the <head> tag on the template. It is not needed for other pages.