There are two main reasons for a project to have a foundation.
Firstly, there's the legal benefits. The foundation can be the legal guardian of copyrights and trademarks associated with a project. Copyrights and trademarks have to be owned by someone -- even if you're open source. Having a foundation provides a way to have some public governance of those legal instruments, instead of having them held by an individual or private company.
Secondly, there's the community organization benefits. If anyone wants to donate money to a project, someone has to accept that money. Having a foundation provides a entity that can accept that money, and then distribute it. As an added bonus, it means that money can be donated in a tax-attractive way (the DSF is a 501(c)(3) not-for-profit, so donations are tax deductible in the US), which makes it easier to attract donations.