Christian has shown what you could do instead but to explain the error
@ is not a letter in the main document so
\let\@var\@empty
does
\let\@=v
then typesets ar\@empty producing the paragraph text arvempty (which you don't see as later errors prevent a pdf being made.
Then
\newcommand{\append}[1]{ \xdef\@var{\@var #1} }
defines \append to typeset a space (why?) and then redefine \@ then typeset another space.
\append{1}
is therefore a space (ignored as we are in vertical mode) then
\xdef\@var{\@var 1}
this is defining the macro \@ to be followed by the tokens var to be the expansion of \@var 1 now at this point \@ is non-expandable as it is \let to v so now \@ has to be followed by var and expands to \@var 1
Then another ignored space is output and
\append{2}
this outputs another space then
\xdef\@var{\@var 2}
which again is redefining \@ to be a macro that must be followed by var but the definition is obtained by expanding \@var 1 but as noted above the expansion of \@var is at this point \@var 1 so the first expansion produces
\@var 1 2
Then \@ expands again producing
\@var 1 1 2
and so on until you run out of input stack. (because the 1's are all being pushed ahead of you)
\makeatletterrequired): did you run exactly this file?1 2 3but123. If you want to have the space in between you have to use\@var\ #1\space.