What is this .file at my root folder?
There's absolutely no reason to delete the file. Note that the file does not take up space on your drive.
The file is not a usual file put there by some program, you've installed. It is part of the operating system, and comes with the macOS installation. It is not meant to be removed.
The file is there to support the operating system feature known as "file reference URLs":
Normally, you know files by their name and folder placement - for example ~/Documents/Letter.docx
.
However it is also possible to reference the exact same file by way of this special file, you're concerned about. The same file could be referenced by something similar to /.file/id=123.45
. This is in many ways similar to using the /.vol
special file which is part of volfs (accessing files by volume number and inode), and similar to referencing files by their inode number alone (only valid on the same file system).
The advantage of this is that a running application can be given a specific file as a normal path/filename, and then reference it by a file reference URL such as for example file:///.file/id=123.45
. This means that even if the user decides to rename or move the file in the file system, the application can still open and access it without knowing about those changes. This is something that typically comes into play when the user drags and drops files on applications.
Note that the file reference URL is a non-persistent reference - meaning that if you unmount that part of the file system, or if you reboot the computer, the URL becomes invalid.