There are two parts to the answer.
One is enlarging the geographic area of capture of wind and solar across diverse climates, to smooth out the exogenous variations. The other is is storage.
Span more climates
Back in the early noughties, Gregor Czisch built a massive optimisation model to look at how to balance a 100% renewables grid at lowest cost, across various geographic areas, as part of his Dipl.Ing degree. His thesis is freely available in German, and the English translation can be bought from the IET. His other papers (some in English, some in German) are freely downloadable.
The model found that increasing the area across which solar and wind were captured, and transmitting that power anywhere across the enlarged area, was one of the cheapest ways to incorporate very high levels of wind and solar into the grid.
Since then, the concept that he and Gregor Giebel developed, of an international supergrid, has really caught on, and the number and size of international electricity connectors (aka interconnectors) has been growing.
Most of Czisch's scenarios, and most subsequent 100% renewables scenarios developed by others, combine this supergrid with storage.
A lot of people immediately think of grid storage as being something where you put electricity in, and that later get almost all that electricity out again. But that round-trip electricity storage is only one type of useful storage for the grid.
Storage balances the grid by time-shifting something to match supply and demand moment-by-moment. Having storage somewhere in the chain between the capture of the primary energy, and delivery of the energy service demand, achieves that.
Storing energy somewhere in the electricity supply chain
Let's look at the electricity supply chain. I'll tag each of the links in the chain with a number, for reference.
Capture of primary energy
Primary electricity generation
Consumption of the energy service.
We can introduce storage at any of those links, to balance the grid.
Biomass in a silo sits at link 1. The primary energy has been captured from the sun, locked up in carbohydrates in the plant matter, and that plant matter is then stored until electricity is needed, at which point it is burnt, and the heat is used to drive a turbine. Similarly, water in the upper reservoir of a storage hydro plant is also energy storage at link 1.
Round-trip electricity storage, such as pumped hydro storage, chemical batteries, flywheels, and ultra-capacitors, sits at link 2.
Once the electricity has been delivered, it has to be consumed. But that doesn't necessarily mean that the end-use of the energy has to happen at that time. It does in some cases - for example if you want light, it's no easier to store pure light than it is to store pure electricity, so electricity consumption and use of light happen pretty much simultaneously. However, most of our domestic energy consumption is for space heating, space cooling, water heating, and water cooling. And it's very easy to store warmth or coolth, for use later. So it's pretty easy to build lots of storage at link 3. Particulary when heating (and maybe cooling) services are provided by shared infrastructure, such as a district heating scheme, where mutli-fuel sources including electricity can be harnessed, and storage of hot water and cold water can be centralised, reaping huge economies of scale.
Some different types of energy storage for the grid, illustrated: