The reason is to get normalized input across various operating systems.
At the time TeX was written, several operating systems used fixed length records, as they were based on punch cards (the typical system with fixed length records). Some of these systems filled the record with NUL characters (corresponding to no punch on a column)

Others filled with blank spaces, for instance IBM's OS360 and VM/CMS (see the quotation in https://tex.stackexchange.com/a/389871/4427).
The problem with the NUL character was solved by using for it category code 9 (ignored), for blank spaces the solution was to remove them when the record is read in before tokenization. Giving the space category code 13 and defining it to be \space would not typeset spaces, because the removal happens before tokenization and every character with category code 32 is removed; after the removal, the \endlinechar is added (but not yet tokenized).
Some TeX implementations (TeX Live, in particular) used to also remove TABs, but nowadays this no longer happens.
In any case, a trailing space would be impossible to spot and could give surprises in output. TeX78 had a different way to cope with endlines, but TeX82 introduced \endlinechar and category code 5, besides space removal.
%, which can be used to leave space in end of line, but it removes\endlinechar. Which undesired effects would arise if space in end of line was kept and\endlinecharwas preserved? – Igor Liferenko Apr 14 '20 at 11:00verbatim*, I believe it is not possible (at least not in a straightforward way) to have lines ending with visible spaces (those printed by\verbvisiblespace). – frougon Apr 14 '20 at 11:57\begin{verbatim*} abc def \end{verbatim*}(there is a newline after\begin{verbatim*}, thenabc deffollowed by one or more spaces, a newline and finally\end{verbatim*}). – frougon Apr 14 '20 at 12:05tex.webnothing is said about removing trailing space) – Igor Liferenko Apr 14 '20 at 12:21tex '\relax abc 'from the command line, and adddef\byeat the prompt, the output will have “abc def” with a space. The space is not stripped in that case. – egreg Apr 14 '20 at 15:19echo -e '\\relax abc \ndef\\bye' | tex. Space is stripped in file mode. So it follows that in your example space is also stripped. – Igor Liferenko Apr 17 '20 at 09:31