Despite not having a very favorable personal image, Richard Nixon still had some serious advantages in 1968 that helped him win the presidential election.
A major advantage of Nixon's had more to do with his opponent's disadvantages than anything else. The Johnson administration was receiving serious blame for the Vietnam War. By 1968, President Johnson, and the Democrats by extension, were very unpopular for getting the United States involved in what was becoming an apparent military quagmire. In response, Nixon presented himself as the candidate with the best plan for winning the war or at least ending it with America's honor intact.
The culture wars of the 1960s also worked in Nixon's favor. With the hippie counter-culture movement dominating the zeitgeist of the nation, Nixon appealed to the so-called silent majority of "regular" Americans. Nixon even seemed preferable to many older moderate Democrats as the candidate to return the country to some semblance of normalcy. Furthermore, the many recent riots and high-profile assassinations in the United States had the majority of the population feeling very anxious. Against a background of turmoil, Nixon presented himself as the candidate who could best restore law and order.
It certainly did not help the Democrats when pandemonium erupted at their own convention. The convention in Chicago was seen by the Democrats as an opportunity to restore the party's image. They hoped that they could undo the perception of themselves as the party of warmongerers and overspending. However, riots at the convention alienated voters who sought a return to order. A the same time, the nomination of the moderate Hubert Humphrey alienated the youth vote by not acknowledging their anti-war concerns. This played further into Nixon's hands.
Lastly, the American Independent Party's rise as a significant third-party in this election worked in Nixon's favor. This far-right party became very popular in much of the South. In response to the civil rights movement which the Democrats had supported, five southern states that Humphrey may have otherwise won went for segregationist candidate Geroge Wallace instead. This robbed the Democrats of crucial states and gave Nixon the edge he needed to win the presidency.