The secretary of defense who served John F. Kennedy and Lyndon Johnson saw his reputation plummet along with America’s prospects in Vietnam.