SharePoint is keep on prompting for username and password

I have created a new farm and for some reason accessing a brand new web application prompted to enter username and password, and even after providing correct credentials I couldn’t log in. Microsoft support provided the following script that resolved the issue :

New-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa -Name "DisableLoopbackCheck" -Value "1" -PropertyType dword