There are a number of issues here that are very complex, and much easier to see in hindsight than they were at the time.
First, the U.S. got itself in a bind by supporting the French colonial regime. Shortly after WWII, Ho Chi Minh attempted to seek U.S. help in freeing Vietnam from Colonial rule. He claimed to be a fan of the U.S. Constitution, and wanted to pattern his government after an American-style Democracy. The U.S. turned him down because France was an ally.
After he was unable to gain U.S. help, he then went to the Soviet Union, and professed to be a Marxist. The Soviets came to his aid, which then dragged the U.S. back into the conflict. Then the French suffered a big loss at Dien Bien Phu, and the U.S. found itself committed to a strategy of fighting the VietCong.
Ho probably wasn’t much of a Capitalist or a Communist. He was an opportunist, claiming to love the philosophy of whoever could aid him. So there was an opportunity lost in steering the VietCong away from Marxism. That’s easier to see now, than it was back then.
The U.S. shouldn’t have ardently supported the French. Colonial rule is not something that the U.S. should have supported. At least at the beginning, Ho had a valid case that the French were trampling the Vietnam people’s right to self-determination.
Anyway, after this happened and Ho made his deal with the devil (the Soviets), all bets were off. The Soviet Union saw Vietnam as a great stepping stone to expand its influence in Southeast Asia. The ‘Domino Effect’ gets ridiculed these days, but it was probably correct - a solid, pro-Soviet government early on in Vietnam would almost certainly have led to the toppling of other governments in the area. Plus, South Vietnam did not want to be Communist, and asked the U.S. for aid. So their presence there was at least moral.
The next question is whether or not the war was conducted properly or morally. I don’t believe it was. War should be a last resort, but once you unleash those dogs you have a responsibility to end it as quickly as possible with a minimum loss of life, while still attaining your objectives. The U.S. didn’t do that. Instead, it tried to use the conflict as a bargaining chip. The ‘rules of engagement’ were ridiculous - supply lines were allowed to stay open, aircraft could not be attacked on the ground, etc. If the U.S. had bombed the daylights out of the Ho Chi Minh Trail, cut off supplies elsewhere, bombed Strategic targets like factories in North Vietnam, and pressed the ground war heavier, they might have brokered a peace much earlier, and with better results.
Instead, the U.S. fought a half-war, constantly scaling back the offensive and allowing the enemy to regroup, almost daily changing the rules of engagement that the soldiers had to obey, etc. Also, far too much of the war was controlled by Washington, which micromanaged a lot of what should have been decided by commanders in the field who were in a better position to know.
Contrast this with the Gulf war - after Bush decided to attack, he turned the conflict completely over to his military command. It was total warfare, until one side capitulated. Imagine if Baghdad had been off limits, if airports couldn’t be attacked (or even aircraft once they land), and if the advancing army was only allowed to move a short distance and then told to dig in while negotiations with Saddam take place. Then, as a show of good faith, the government ordered the troops back, then weeks later commanded them to re-take the same ground they took the first time… If the Gulf War had been fought like the Vietnam war, it could have been a quagmire that cost far more lives than it did, on both sides.