Vietnam failed because Kennedy decided to eliminate Diem who did have and would have retained the loyalty of the Vietnamese people. No one else could replace him and the rest was inevitable as the insurgency grew with every scrap. The insurgency itself was beaten badly by US arms but that could not stop an outright invasion then supported by the people who then loathed or at least did not trust the successor government..
The USA always had real strategic options that could have won the day even then. They never used them. Yet the original mistake began with the assassination of Diem.