How to restore Mac without deleting files
Solution 1:
You can boot into macOS Recovery by pressing Cmd-R at startup, from there you can reinstall macOS. This should leave your files intact, it's nevertheless not a bad idea to do a backkup first.
Apple has described the procedure in detail in https://support.apple.com/en-us/HT201314 and https://support.apple.com/kb/HT204904.