What exactly happens when a country runs out of money?

And why it’s not as simple as printing more money