Kennedy and McCarthy were both Democrats. President Johnson, also a Democrat, was eligible for another term (he had served the remainder of John Kennedy's term and was elected on his own in 1964). Everyone expected him to run for another term, so it was a bit of a surprise when Senator McCarthy launched a campaign. In the New Hampshire primary, McCarthy polled 44% of the vote, contrasted with Johnson's 49%. This was a surprising outcome. McCarthy was running as an anti-war candidate; Johnson's policies in Vietnam were becoming increasingly unpopular.
Kennedy didn't enter the race until after the New Hampshire primary. McCarthy and his followers considered this a betrayal and planned to defeat Kennedy.
McCarthy had become a candidate in the first place due to a group of anti-war Oregon democrats. They had initially approached Kennedy to run as an anti-war candidate, but he refused. McCarthy was their second choice candidate, and he agreed to run for President. So, the two of them were considered to be fairly similar in political views, in that both were opposed to escalating the war in Vietnam. Many of McCarthy's early campaign workers were supporters of Kennedy, and left his campaign to join Kennedy's.
Kennedy's platform included social and economic justice, anti-war, and social improvement, in particular civil rights (although it has since come to light that he authorized the FBI wiretap on Martin Luther King's phones because they were all afraid Communists had infiltrated the civil rights movement). McCarthy was chiefly an anti-war candidate, but he also supported civil rights, minimum wage, more federal aid for education, and wanted federally-funded anti-pollution programs. Politically, the two candidates were virtually identical.
Character-wise, it could be argued that McCarthy had more courage. He challenged a sitting president of his own party. Kennedy didn't enter the race until after McCarthy had shown that Johnson was vulnerable.