The U.S. took over Vietnam when the French were kicked out of Vietnam in (1954). A civil war was raging between North and South Vietnam. The U.S. (during Eisenhower's presidency) sent troops to South Vietnam to train the South Vietnamese Army. When Kennedy became President (1961) he inherited a messy situation. In the fall of 1963 Kennedy ordered his Secretary of Defense and Secretary of State to assemble all the data for his (Kennedy's) decision to withdraw from Vietnam or remain helping the South Vietnamese. Kennedy said he would decide when he returned from Dallas, Texas where he was speaking November 22, 1963, to prepare for the 1964 presidential election. Seemingly, most political pundits thought Kennedy would remove the American troops from Vietnam.
So we were in South Vietnam for the right reasons, but Lee Harvey Oswald ended that, and the rest is history.