Is there any need for the ending of 'to myself'? How is it different from the alternative? Can you always replace 'I thought to myself' with 'I thought'?
This is not redundant; it removes some ambiguity. For example,
usually isn't really describing a specific thought - just a belief about what I did and where my keys are. But it could also mean - a definite thought passed through my mind, and that thought was "I left my keys on the table".
If I wanted to express the latter sense, I could make it clear by specifically saying something like
which would generally mean that a definite thought passed through my mind.
Any need for it? No. It's redundant.
But redundancy is a feature of language, not a bug. Although the denotative meaning of "thought to myself" and "thought" are the same (barring telepathy), they can have different connotations, moods, or styles. Reputable authors have used the longer version, e.g. CS Lewis in The Voyage of the Dawn Treader:
...which is in part of a story about an unusual personal experience related by an English schoolboy. So in the end it's just a style choice, not really a meaning-based one.
EDIT: But there may be a difference in connotation. The connotation of "to myself" puts the emphasis on the reflexive nature of the thinking, and not simply on the thought. Many translations of Ecclesiastes 1:16 have something like:
where the KJV translation has: