The \ sign makes the interpreter interpret the next sign as a character instead of an identifier.
You see it a lot in code as well:
"Hello \"World\""
this is interpreted as
Hello "World"
in your example, in order to pass the arguments to cmd, it needs to be enclosed in "". But since the arguments to cmd contains " (and this would end the enclosure) they are appended by \. If the "" would not have been there, the /k dir \"%userprofile%\" would have been interpreted as arguments to runas, not to cmd.
The reason why they are enclosing the %userprofile% is because this is an environmental variable and will be replaced by text which could contain spaces, which (for the same reason as above) would make the argument to cmd incorrect.