In typesetting context, the expression
\the\myToken is fully expanded and typeset in TeX's stomach. Thus the expected result is
\typeout is defined in
In this context (
\immediate\write) the expression
\the<token register> is expanded once, but the contents of the token register is not expanded further.
From "The TeXbook", "Chapter 20: Definitions (aka Macros)":
Expanded definitions that are made with
\xdef continue to
expand tokens until only unexpandable tokens remain, except that token
lists produced by
\the are not expanded further.
\immediate\write is not
\xdef, thus we also need:
TeX's primitive commands
expand the token lists in braces almost exactly as
do. However, a macro parameter character like
# should not be
duplicated in such commands; [...]
Thus you need to trigger the expansion twice to get the contents of the token register expanded.
Token register can be used to simulate eTeX's
\unexpanded (however the construct will be non-expandable,
\unexpanded is expandable). For example, this is used in
latex.ltx) that adds some tokens in the second argument to the macro in the first argument:
#1 is expanded once and the result is put into a token register with the additional
#2. The following
\xdef defines the macro with its original definition text with the tokens in
Expansion of token register inside
The contents of a token register looses their non-expandable behavior if it is touched twice:
\typeout should not be redefined, the contents of token registers can contain stuff that breaks, if it would expanded (undefined commands, endless recursion, ...).
Also it would disturb the usages of
\typeout for other, is the tokens where suddenly expanded.