When I was growing up, the word gringo was not used in an antagonistic way, but also not in a friendly one. In PR we use the word to denote someone from the United States, and many times it was to say something like, "That tourist can't dance - must be a gringo", or "Of course he doesn't like morcillas, he's a gringo". While I never detected outright hostility in the way the word was used, the subtext was one of condescension, of "look how different that outsider is from us". And it's not just any outsider - it's a word that in PR separates us and our idiosyncracies from those of neighbors to the north.
I've noticed that some Americans do not have a problem referring to themselves as gringos - mostly because they may not fully understand the usage of the word. Usually this happens when in the company of Hispanics, and they'll jokingly call themselves that name in order to show that they understand that they are different, and to subtly explain why they can't dance, or why they just don't like to eat blood sausage. They're just gringos, and therefore cannot help such shortcomings.
Puerto Ricans have started, throughout the years, to use the term more loosely. They may call someone from the States a gringo with no other context within the conversation that would indicate anything other than, simply, identifying him or her as an American. Another word, gringolandia, meaning gringoland, has popped up, and it refers to the US itself. Again, most of the time its usage denotes an "us and them" mentality; it points to things you never in your life saw or knew about until you moved to or visited gringolandia.
You will meet some Spanish-speakers who see nothing approximating an insult in the word gringo. It's just another word for an American, they say. The word in Spanish for someone from the US, estadounidense, is long and cumbersome - which is why I more often use americano, another word that is frought with its own cultural perils - so we just call them gringos. You'll meet others who believe that it's meant to be insulting. And most of us Spanish-speakers cannot even agree on the etymology of the word. The old story that it comes from a song sung by soldiers in the Mexican-American War, "Green Grow The Lilacs", has widely been debunked. Some say that it comes from the same time period, but refers to the phrase "green go", in reference to Mexicans urging Americans, in their green uniforms, to leave. Again, given that the word was in use before the war (it was noted in a Spanish dictionary from 1750), and the Americans wore blue, we can assume that theory is implausible as well. A third theory states that it comes from the Spanish for "speaking Greek", which means much the same as the phrase "sounds Greek to me" in English. In any case, just one look at the discussion section of the Wikipedia article for the word gringo shows just how much debate surrounds this word. The article itself is flagged as possibly being biased and not factually correct. One commenter's argument that using it alone is neutral, but using it with pinche (a Mexican-slang expletive) makes it an insult, somehow rings hollow.
I find myself in the middle of the debate regarding its meaning. I can only speak to its usage in PR and not to how it may be used in other Latin American countries, but while I don't find it to be a particularly virulent word, I don't find it to be harmless, either. I see this word as an attempt to draw a line that separates "us" from "them", and not just in the obvious way that any name based on nationality would define people. If you see an American doing something you wouldn't do, he becomes a gringo. If you see an American not quite "get" your culture, he becomes a gringo.
Little by little, I see this word take on a life of its own. It highlights cultural differences that we may not understand, but it doesn't urge us to try and understand them, rather, it leads us to dismiss those differences and assume that, when it comes to us and them, ne'er the twain shall meet. Unfamiliar situations can become distasteful and something to avoid if we simply categorize them as "things those gringos do".
As to how the word originated, while it may have been in use as early as the 18th century, it's hard to say what the hidden meanings of the word were, if any. It may well have started out being a neutral word, but at some point in its history it took another turn. If some today do use the word in a completely neutral way, with no connotations whatsoever, I believe it's the result of a charged word becoming more and more commonplace. Is this a good thing? Is power being stripped from a word, or are we falling into using once-unfriendly words so often that we no longer think about it? How would we feel if Americans started to use such names about Hispanics so often that they became commonplace?
If these questions have definite answers, they'll be coming from minds greater than mine. There are likely many Spanish-speakers who disagree with my view on the g-word.But for myself, the word gringo is one I choose to avoid. Were I on a Randal Graves-like crusade to take back the word, I would venture to use it more often. But, alas, I cannot dream of being as brave as he.