Benefits of financing a car vs. buying in cash

I’m trying to see what the pros and cons are to buying a car in cash vs. financing it. I’ve read a lot of old posts here, and the one pro for financing that keeps coming up is that “if you finance it, you can take the money you would’ve spent upfront on the car and invest it instead”. But what does that actually look like?

Say I want to buy a car for $20k. If I decide to finance it instead of buying it all in cash, what exactly am I supposed to invest that $20k in? And would I just sell some of that investment every month to pay the monthly payments? As my employer handles my pension, my only investing experience is the ~$1k/year I put in an index fund in my IRA, and I’ve never sold or taken any of that money out, so I’m kind of lost here.