Though the biggest protests against the war didn't start until 1967, by 1966 people had already begun burning draft cards and two protestors had self-immolated. The protest song "For What It's Worth" also came out that same year, and has remained famous while Ballad of the Green Berets is relatively obscure.
Who was listening to this sort of song? If such a thing was popular in this instance, why weren't there more like it? What did fans of the song think when anti-war songs soon started to become popular? Was there any negative reception to the song from those who had already turned against the war? Is it possible it was only or mostly popular because of its musical qualities, independent of the content of its lyrics? Were people deliberately listening to it as a show of support for the war or did they just enjoy a song that happened to be military-themed?
As you say, 'The Ballad of the Green Berets' was clearly out of step with pop music's culture in 1966, the year 'Paint It Black' by the Rolling Stones and 'Good Vibrations' by the Beach Boys got to #1. But then the big singles often do come from outside of pop music culture. The group of people who were 'in' the culture of pop music at any one time is relatively small; they're usually young and experimenting with their identities. There is, and always has been, a much larger audience for singles amongst people who don't keep up with the times (i.e., adults, who often have more disposable income than teenagers), but the problem is often getting people in this much larger audience to realise that the song exists. For the likes of 'My Heart Will Go On' by Celine Dion or 'Everything I Do (I Do It For You)' by Bryan Adams, the song was the theme of a movie (and so guaranteed getting heard by people who otherwise would not be that interested in the flow of pop music trends.) Elton John's 'Candle In The Wind '97', a charity single associated with the death of Princess Diana, benefited from the outpouring of sentiment after her passing. So at a basic level, 'The Ballad of the Green Berets' was one of these songs - not really 'with it' in terms of pop music in 1966 (the year psychedelia really exploded into American pop culture). And it was one of these songs - it was the best selling single of the year.
More specifically, the Green Berets (the US Army Special Forces) had been lionised in American culture in the mid-1960s, and 'The Ballad of the Green Berets' was part of this; in 1965 (while Barry Sadler was in Vietnam with the Special Forces) an (almost) best-selling book was published - Robin Moore's The Green Berets which claimed (in its introduction) to be 'a book of truth'. In 1968 the book was turned into a strongly pro-military film co-directed by and starring John Wayne. Sadler was injured in Vietnam, and needed to be flown out for medical treatment. During Sadler's convalescence, he made a demo of a song called 'Ballad of the Green Beret' which generated some interest from publishers; Sadler continued to record demos of his songs. Robin Moore met Sadler, and worked on a revision of 'Ballad Of The Green Beret' with an extra verse, now called 'Ballad Of The Green Berets' (to ape the title of the book).
Recorded in December 1965, the song became a hit in early 1966, and it was widely seen as a rebuke to anti-war songs like Barry McGuire's 1965 'Eve Of Destruction'. In terms of its success, Roger Landes argues in a chapter of the edited book The Vietnam War In Popular Culture titled 'Sgt Barry Sadler and the Ballad of the Green Berets' that Sadler had a few things going for him. Firstly, he was a serving Green Beret who had suffered an injury in service, which gave his song a powerful ring of authenticity (something that was not shared by the pro-war country songs of the era, which were relatively common but did not translate into wider pop culture). Secondly, 'The Ballad Of The Green Berets' was released a couple of months after the Battle of Ia Drang, the first big engagement between American troops and the Viet Cong, where hundreds of American soldiers died (Sadler himself was in convalescence before this battle). Sadler thus rode a wave of patriotism in popular culture which was spurred on by the shock of this battle to the American public; Landes compares the effect of these deaths to the effect of the death of John F. Kennedy. 'The Ballad of the Green Berets' also wasn't 'pro-Vietnam war' in its message, per se, but was 'pro-soldier', which was perhaps easier to sell to the American public. Thirdly, Sadler's record company RCA could smell the wind of late 1965/early 1966, and so they put a bunch of resources into promoting and publicising the song, helped by the US Army's marketing team, which too saw the song as a golden publicity opportunity, and which made sure Sadler was available for the promotional opportunities that RCA could offer.
Landes also makes the point that the success of Sadler was very short-lived. 'The Ballad Of The Green Berets' was of a particular moment: as Ia Drang faded from memory, so did 'The Ballad of the Green Berets'.
In terms of negative reaction from those who were against the war, the pro-soldier nature of the lyrics, which didn't voice any specific pro-Vietnam War sentiment, diffused this to a great extent; the song was seemingly interpreted more universally as being about war rather than being about a specific war. The teen fortnightly magazine KRLA Beat in April 1966 ran a 'teen panel discussion' on the topic of 'Ballad of the Green Berets' (which is also a reminder that, despite the song having a wider appeal than most pop music of the era beyond the usual teenage baby boomer audience, that it was still something that was consumed by teenagers). There are some interesting quotes from teens in this article, who KRLA Beat implies were anonymised:
BILL - [one trend] creates the next. After all that 'down with war' stuff, the time was perfect for songs like 'Green Beret'. We were just ready to be exposed to the other side of the story. Ready psychologically. I think a lot of teenagers bought 'Green Beret' because they felt guilty about going along with the protest idea. After all, there is a war going on.
JOANNE - ...I don't think 'Green Beret' is nearly as patriotic as a lot of the protest songs. Those songs were against destruction. 'Green Beret' almost sounded like it was for it. In my opinion, it's far more patriotic to want to learn how to live than it is to want to learn how to destroy life."
MARI - That's ridiculous! 'Green Beret' was a hundred times better than any protest song could ever be, and I'm really proud of kids for coming to their senses. How can you say that song was for destruction? It encouraged people to stand behind their fighting men, and it encouraged those men to be better soldiers.
PAUL - You've got to be kidding. That song sounded like a Madison Avenue advertising campaign to promote war. It made being 'tranined in combat hand to hand' sound glamorous! And that part about pinning wings on his son's chest. If it hadn't been for that, I wouldn't have been offended by the song. But that did it. No responsible parent would wish that kind of future on a child...
(skipping to later in the panel discussion...)
MARI - ...I never stopped to think that it really is the same kids. The one who bought protest songs are buying things like 'Green Beret' now. I don't think it's because they feel guilty. I think it's just because they're willing to listen to both sides. Adults could learn a few lessons from teenagers.
Clearly the members of the baby boomer generation that made up this panel discussion show a range of political ideologies. Mari is clearly strongly in favour of the song, bu others say they were offended by it - more for its implications of glorifying violence than the Vietnam War itself, which none of the panel members ventures strong opinions about in particular.