A large, cold, dilute gas of hydrogen and space dust collapses slowly under its own gravity, compression, heating, and fusion take place aided and abetted by shock waves, and then a star glows for millions to trillions of years.
That’s how it is usually explained but the numbers are hard to grasp. The clouds can be dozens of light years across, the gas pressures are lower than the best vacuums on earth, the shock waves aren’t the kind we associate with sonic booms, and it can take tens of millions of years to get the party started.
Yet it happens and we are here because of it. The details are very tough sledding but equally interesting.