if you...
1. type SET or set at the prompt
2. run the code changing it slightly like this
del myset.cmd & FOR /F %V in ('set') do echo SET %V >> myset.cmd
(It is bad practice to have a command script with the same name as a built in command)
3. examine the contents of the new file myset.cmd (which is a script)
... you will see for yourself what it does - namely that FOR /F captures the output of the command 'set', line by line, into the loop metavariable %V, and the >> operator echoes these lines, (with the word SET and a space prepended), in append mode, to the named file myset.cmd.
Type FOR /? and SET /? at the prompt for more help.