I vaguely remember reading that the word Gringo came from some Texas Americans who became prisoners of war in one of our fights with Mexico. While they were being marched off to some prison camp they sang a song that had the refrain:
"Green grows the ... in Texas".
"Green grows" got bastardized into "gringos".
I have no idea if it is true.
I read somewhere that the word gringo was used by Spanish-speaking people before the birth of USA. I was a corruption of the Spanish word for Greek,
griego, and it applied to foreigners in general.
In other words, nobody knows.
This guy seems to know that these questions do not require historically accurate answers, just funny retorts.