/var/folders can be thought of as macOS's modern way of doing
/tmp. It's a place for apps to write temporary files, so that your data is safe/recoverable even if you haven't explicitly saved your edits/changes yet. The random-ish names avoid name collisions.
If you do a…
sudo find /var/folders | more
…you'll see that lots of apps and services write stuff there.
When you use the
funced fish command it writes the function definition to a temporary file then launches your editor with the name of that file. As @Spiff points out in his answer the specifics of the temporary file name depends on the OS. It is also affected by environment variables such as
$TMPDIR. The reason such "bizarre" path names are created is to avoid collisions with temporary files created by other processes.