For the most part, you should not set
TERM manually. The variable is always set automatically, and there is only a narrow set of circumstances where the default value is incorrect.
The value of
TERM needs to be referenced in the system's terminfo database (or for a few old-fashioned system, in the termcap database). Terminfo and Termcap map terminal types to the description of terminal capabilities that applications use. The value of
TERM is the terminal type.
The main reason why you might sometimes need to change
TERM is if you log in remotely, when the local machine and the remote machine have different terminal databases.
Another reason, which is related to the previous one, is that sometimes there are multiple similar entries for a terminal, with slightly different capabilities. This tends to happen mostly when a new terminal comes up which is compatible with an existing terminal, but has more features. You then get a choice between using the traditional name, which all machines understand, but which advertises only the traditional features, or the newer name, which advertises all the new features but which some machines won't understand.
An example of this is xterm with 16 colors vs xterm with 256 colors. A traditional xterm supports only 16 colors, so that's what the
xterm terminal database specifies. Changing the
xterm entry would make users of the newer xterm versions happy, but would break the configuration of users of older xterm versions who log in remotely. Switching to a new name —
xterm-256color — provides the newer capabilities whenever available, but is not recognized if you log in remotely to machines with an older terminal database. Because there is no solution that can satisfy everyone, you get a choice: either stick with
xterm and don't get the 256 colors, or use
xterm-256color which doesn't work if you log in to remote machines that don't support it.
Leaving the default value of
xterm and setting the
termName resource to
xterm-256color (which causes the environment variable
TERM to be set to the same value) are thus both sensible choices. Setting
TERM to arbitrary values wouldn't work, but both
xterm-256color make sense.