Daenerys' father wasn't the first mad king in Game of Thrones. Targaryens have a history of going mad. Not all of them, of course, but more than any other family in the series, it seems. In the books, this bend towards madness is referred to as "the taint," with most people believing it's an inherited trait that runs in the Targaryen family blood.
In the books, Dany initially believed people had lied about her father Aerys II's madness. She didn't believe he'd made the call to burn his people alive. Ser Barristan Selmy is the one who educated her in the books. He said:
"Every child knows that the Targaryens have always danced too close to madness. Your father was not the first. King Jaehaerys once told me that madness and greatness are two sides of the same coin. Every time a new Targaryen is born, he said, the gods toss the coin in the air and the world holds its breath to see how it will land."
Some characters in the books believed that Dany's brother Viserys was another mad Targaryen — which lines up when you think about how, on the show, he threatened to kill Dany and her baby if he didn't get a crown and army from Khal Drogo.
Other mad Targaryens in the books include King Maegor, King Baelor, and Prince Aerion. Not all of the mad Targaryens were as "mad" as Aerys. Some madness manifested in odd behavior and occasionally their "mad" actions did hurt themselves, like when Prince Aerion drank wildfire thinking it would turn him into a dragon, but he just died instead.
It's the Targaryen connection to dragons that actually has many readers theorizing that the extinction of the dragons is what helped turn the Targaryens mad. Whatever is in their blood that allowed them to bond with these mythic creatures is perhaps unstable without the dragons beside them.
More likely, though, the madness is just a result of years of inbreeding. As Cersei told Ned Stark in the show, "Targaryens wed brothers and sisters for 300 years to keep the bloodline pure." What they were really doing is harming the bloodline, because those genes are too close for comfort. The incest theory would also explain why Joffrey was so maniacal and Tommen so withdrawn. Their parents were also siblings: Cersei and Jaime Lannister. If you're wondering how Myrcella escaped that madness, it may be because she was a girl.
Reddit user anycullen claimed that the only Targaryen woman to go mad was Haelaena Targaryen, and that was only after her child was murdered in front of her. That's certainly enough to make anyone upset. As for the rest of the "mad" Targaryens, it seems it was a "taint" to their blood, in just that they were too inbred and it negatively affected some Targaryens' minds. Not all of them have been so affected, and the women much less so. In any case, Dany and Jon should probably stop their relationship for good — the Targaryen family line doesn't need anymore incest.