What were the goals of United States intervention in Vietnam from the 1950s-1970

What were the goals of United States intervention in Vietnam from the 1950s-1970s? What was the justification for the war, and did that justification reflect the reality of US intervention?  What problems (both in Vietnam and in the US) did the military face fighting the war, and how did those problems contribute to the outcome of the conflict?