The theory that Tyrion is the son of Aerys II Targaryen mainly stems from two passages in the books:
First, in A Storm of Swords (Book 3) Tywin says this to Tyrion as a rebuke when the latter claims succession to Casterly Rock (emphasis mine):
"Men's law give you the right to bear my name and display my colors,
since I cannot prove that you are not mine."
This passage has also made it's way to the TV series (episode 1, season 3).
Second, in A Dance with Dragons (Book 5) Ser Barristan tells the following story to Dany about her father, Aerys II (again emphasis mine):
"Prince Aerys... as a youth, he was taken with a certain lady of
Casterly Rock, a cousin of Tywin Lannister. When she and Tywin wed,
your father drank too much wine at the wedding feast and was heard to
say that it was a great pity that the lord's right to the first night
had been abolished. A drunken jape, no more, but Tywin Lannister was
not a man to forget such words, or the ... liberties your father
took during the bedding."
There are a few other more subtle indications that some have taken as support for this theory: Tyrion's fascination with dragons, his odd hair coloration (pale blonde as opposed to the golden blonde the Lannisters are famous for), and narratively the fact that he seems to be on his way to unite with Dany.
However, there are several problems with this theory. Tywin's hatred of Tyrion can be easily attributable to the latter causing his mother's death during birth. Something Cersei holds against Tyrion as well. Doubting Tyrion's paternity could very well be Tywin lashing out at his son out of grief, since by all accounts Tywin was deeply in love with Joanna, and he isn't exactly the forgiving type.
The account of Aerys taking liberties with Joanna is also not without problems for this theory.
Barristan's story indicates that Aerys did something objectionable
during the bedding. In Westerosi culture, the bedding is the name
given to the first time a husband lies with his bride (sometimes
witnessed by the feast's guests who have had too much to drink). So if
anything, this story casts doubt on the paternity of Joanna's first
born: Jaime and Cersei, not Tyrion.
Sure, Aerys may have raped or seduced Joanna at a later date, but
apart from his known lust for her we have no evidence of this ever