but if Apple is has cash in the bank
They have it in short term corp bonds and US Treasuries. Corp bonds is basically what a bank does. Do I want Apple to go into banking? US Treasuries – well that’s money to the government – not what I would consider investing.
My understanding was there are limits to how much earnings a company can retain.
Nope, there are no legal limits.
By holding cash and not paying dividends or doing stock buybacks, they're essentially deferring taxes forever.
Taxes are paid on earnings – i..e. when the profit is made. Not when that profit is distributed – i.e. dividends and buybacks.
One could argue that the retained earnings are reflected in the stock price
This is true.
I'm effectively paying more capital gains tax
Yes, but you would be paying lower taxes. Cap Gains taxed are lower than personal income – which is rate of dividends – if you ignore the QDI / DRD rules.
But you can get the same lower tax rate with a stock buyback.
Which leads to the question – why am I investing in Apple? It’s not because they are earning the rate of inflation on their cash pile. If I wanted that I could open a bank account. That cash should either be put to work doing something that will earn more than bank account or be returned (less any money need for a rainy day or such – but Apple has not explained why it needs so much rainy day money.).