S=I in a closed economy In a closed economy, the national income identities imply that $$S=I$$

However, the intuition is not clear to me. The saving is the part of national disposable income that is not consumed. $I$ is the sum of residential and nonresidential investment. When firms invest, they generally borrow to finance that investment. However, why is it the case that this would necessarily equal aggregate savings? Individuals might save, but firms (or households) need not borrow. Does $i$ include idle funds as well?
This is a macroeconomic tautology, and like many others, the words often do not have their commonly expected meaning.  In particular saving and investment are not directly about money but about stuff measured in money terms

Suppose you had an economy based purely on grains of wheat.  The real activities are:


Plant wheat grains, grow them and harvest them, getting more grains as a result
Consume wheat as food
Store unconsumed wheat for future planting or consumption


In this case, macroeconomic saving is the amount that production exceeds consumption while macroeconomic investment is either increasing stored stocks or the planting of grains for future production.  (If you were wondering, grains which rot after having been purchase by consumers still count as consumption, while grains which rot while in producers' storage count as negative investment.)  So in this case, both saving and investment  measure the same thing, seen from different perspectives.

Clearly you could measure this particular economy purely in grains of wheat, but if you want to do so in money terms then you would need to know the price of wheat, where say a million grains are worth $\$5$.  This would then allow you to incorporate the production and consumption of other stuff into your calculations, such as barley where say a million grains are worth $\$3$ and yields are different, or beer produced from barley and bread from wheat, or anything else.  But saving representing unconsumed production, and investment representing the other non-consumption uses, would remain equal, almost by definition