Ars has a piece going into more detail on the IRS's reasoning for this. For starters, open-source software can, inherently, be sold as a commercial product.
One of the key facets of open source software licensing is that there are no restrictions imposed on specific fields of endeavor—open source software can be used by anyone for any reason. As such, a software license that prohibits commercial use is, by definition, not an open source license. However, the question of whether a piece of open source software is developed for commercial purposes is distinct from whether it is ultimately used commercially by some of its users.
It isn’t impossible to understand where the IRS is coming from. Consider a company like Canonical, a commercial software vendor that includes one of Yorba’s applications in its own product. If Canonical makes a donation to Yorba that funds development of that software and consequently benefits Canonical’s business, it isn’t unreasonable to question whether it's really fair for that donation to be tax-deductible.
Which I guess makes a certain kind of sense if you look at it from just the right angle and squint.
But then there's this:
In addition to contending that the possibility of commercial usage makes open source software fall outside the boundaries of 501(c)(3) status, the IRS also shockingly asserts that open source software has no intrinsic educational value. In its rejection notice to Yorba, the agency claims that “anything learned by people studying the source code is incidental.” While I may have been able to see at least a hint of logical basis for the agency’s concerns about commercial usage, its opinion about the educational value of open source software defies all reason.
"Shockingly" and "beyond all reason" are pretty good adverbs. Learning by studying code is "incidental" to open-source software in the same way that learning about building is incidental to playing with Legos and jumping on Goombas is incidental to playing Super Mario Bros.