I think dividends in a tax-exempt accounts, like a traditional IRA, are only not taxed if you reinvest the dividend or just leave it in your brokerage account.
Right. Although, with a ROTH IRA, you pay taxes before you put the money in. Then you earn tax free even after you take it out. That makes it the preferable vehicle for long-term savings (you should expect your initial investment to double every 10 years, assuming a 7% ROI which is fairly modest - so over 30-40 years you’re saving 8x on the eventual withdrawal).
But this isn’t just limited to IRAs. Using investment funds, you can pull the same trick. Buy the fund, then allow the broker to shuffle the investments within the fund as they please. You only “earn” the money when you exit the fund, in the same way you only “earn” your retirement when you withdraw from your IRA.
Savings accounts and trusts can then be structured to be inheritable tax-free, with your heirs having access to withdraw from the fund without ever actually owning the money (and thus needing to pay taxes on the inheritance). And to make it even more squirrelly, you can borrow against these funds, which allows you to make large purchases without ever actually spending any money. This maneuver, plus a cagey use of declared loses, means you can avoid paying any tax on any investment income virtually indefinitely.