I always found it hard to believe that Tywin Lannister simply decided to stay neutral during Robert's Rebellion.
Westeros is going through its greatest game-changing moment in decades (maybe centuries) and Tywin stays home at Casterly Rock, basically doing nothing and looks on from the sidelines while the other Great Houses are changing history? Seems very ooc to me. Plus he must have known that no matter who'd emerge as the winner, staying out of the conflict will make House Lannister lose influence.
Nobody gaines power or respect by refusing to fight or by joining battles late (see 'the Late Lord Frey') and chaotic times are always great for improving the importance of your house if you are a capable military leader and know how to play the game.
Staying out of the war only brings disadvantages:
If the the rebel alliance wins then House Lannister will overnight turn from being the most powerful
house after the Targs into only being the 5th most powerful house in the realm. The Baratheon/Stark/Tully/Arryn alliance has no reason to grant the Lannisters any kind of influence during Robert's reign. He also endangers Jamie's life in case the rebels manage to sack KL. 5 of the 7 KG members died defending the Targs (and Barristan would have died if Robert had not intervened) so chances that something might happen to Jaime were high, too high for Tywin to risk it, no matter how pissed off he was with King Aerys.
And if the Targ forces win the war his position of neutrality will again cost him. It will be noted that the Westerlands ignored the King at a time of great peril unlike Dorne and Highgarden who helped defend the IT and will be rewarded with influental positions.
I totally get that Tywin doesn't want to defend the Mad King or rally his bannermen because Aerys ordered him to but what if Prince Rhaegar had personally reached out to him?
Looking at Rhaegar's position it seems even more obvious how useful an alliance with Tywin would have been for him. He is already fighting 4 Great Houses and he knows that Lord Tywin who currently stays neutral in the conflict hates his father for stealing his heir. At the very least he should personally assure himself that the Westerlands will keep staying out of the fighting since if they decided to join the rebels Rhaegar must know he will lose the war.
But let's say they are already in contact by raven, why not ask him to join him personally (not fight for his father but for Rhaegar himself)? Many people believe that the changes Rhaegar mentioned in his last conversation with Jaime was him planning to overthrow his father after the war with the help of a the Great Council. If that's true then he could offer Tywin his old postion as Hand back and more importantly promise to release Jaime (with honours) from his KG duty once he's the new king.
An alliance would be extremely beneficial for both of them, so why didn't it happen like that in the books?
I think Rhaegar reached out to Tywin a bit too late and when the Westerland bannermen were assembled and ready to go to the Trident Rhaegar was already dead. Tywin realized that with the prince dead the war was lost (also the Handship and getting Jaime back all depended on Rhaegar) and changed direction and sides in the war and rushed his men to KL to sack the city/save Jaime/order the killing of Targ children/prove to Robert&Co that he was on their side.
Why does no one ever talk about this secret pact?
Only the Westermen riding with Tywin know about it and he made it clear to them that no word about this alliance is allowed to ever get out and that the loyalty of the Westerlands to Robert's cause must not ever be doubted.
Why does it matter?
Now that most of the key players of Robert's Rebellion and especially Tywin himself are dead some Westermen who stayed silent for years (out of fear and/or respect) might start talking
It might change Dany's opinion about House Lannister if she ever finds out about it
It would be a revelation that turns reader expectations upside down
It would explain Tywin's and Rhaegar's odd behaviour during RR (Tywin not willing to get engaged in the conflict until literally the final moment, Rhaegar overly confident that he will win at the Trident against very strong enemies)