Two-Face first appears in Detective Comics #66 with the name Harvey "Apollo" Kent; later stories changed his name to "Harvey Dent" to avoid an association with Superman (Clark Kent).
The character only made three appearances in the 1940s, and appeared twice in the 1950s (not counting the impostors mentioned below). By this time, he was dropped in favor of more "kid-friendly" villains, though he did appear in a 1968 issue (World's Finest Comics #173), in which Batman declared him to be the criminal that he most fears. In 1971, writer Dennis O'Neil brought Two-Face back, and it was then that he became one of Batman's arch-enemies.
In his autobiography, Batman creator Bob Kane claims to have been inspired by Robert Louis Stevenson's Strange Case of Dr Jekyll and Mr Hyde, specifically the 1931 film version which he saw as a boy. Some inspiration was also derived from the Pulp magazine character the Black Bat, whose origin story included having acid splashed on his face.
In the wake of Frank Miller's 1986 revision of Batman's origin (see Batman: Year One), Andrew Helfer rewrote Two-Face's history to match. This origin, presented in Batman Annual (vol. 1) #14, served to emphasize Dent's status as a tragic character, with a back story that included an abusive, alcoholic father, and early struggles with bipolar disorder and paranoia. It was also established, in Batman: Year One, that the pre-accident Harvey Dent was one of Batman's earliest allies. He had clear ties to both Batman and Commissioner Gordon, making him an unsettling and personal foe for both men.