There are many specific reasons, but most broadly, it has frequently been shown (us and the British in our Revolution, Britain and India, France and Algeria, France and Indochina, us and Vietnam, Soviet and Afghanistan, etc.) that a major military power fighting a limited war (from their perspective) on the home turf of a less developed military power that is fighting total war is going to be worn down, eventually.
More specific reasons. Of these, the most important is that we never had a strategy to win. When McNamara resigned as SECDEF, LBJ sent McNamara's replacement, Clark Clifford on a fact-finding mission to Vietnam: find out what the generals need and how we get them. It pretty much went like this:
Q: What do you need?
A: Many more soldiers.
Q: OK, what will you do with more soldiers?
A: Kill more VietCong.
Q: OK, what's your plan? What do we need to do to win and how will we know we won?
A: When we killed enough of them.
Clifford went back and reported that the generals had no plan to win and there was no route to winning. From then on, LBJ was wholly motivated to try to figure out how to get out.
Another problem, the South Vietnamese were never as motivated as the North. We made the mistake of thinking South Vietnam was a different country but in fact, they were all Vietnamese and many southerners viwed Ho Chi Minh as the man who fought to iberate their country from the Japanese and the French and us as the latest in a string of occupiers. It turned out after we left that many senior military officers and government officials were really working for the North.
Finally, the corruption and incompetence of what we did worked against us. Bombing from B-52s flying five miles or more above the earth, long range artillery, and "zip in and zip out" raids in helicopters were almost as if calculated to alienate civilians.