You can get the content of the first 8 books or so for free, legally, from WotC's site:
Originally found here: http://www.wizards.com/default.asp?x=d20/article/srd35
As of today (April 5th, 2019) while this link is still active, the files 404, but the Internet Archive still has them. (See links in comments) The rtf files contain the majority of the content of the following:
- Player's Handbook
- Dungeon Master's Guide
- Monster Manual I
- Expanded Psionics Handbook
- Manual of the Planes
- Epic Level Handbook
- Unearthed Arcana
- Deities and Demi-gods
This is referred to as the SRD, or System Reference Document, and is legally free content released by Wizards of the Coast.
It has more than what you need to play the game. It contains all the rules text, but is missing the fluff text.
It is formatted differently than the books, being organized by subject instead of by chapter. Some people find this easier, others find it harder to find things.
There are also online repositories of this content, for example the http://www.d20srd.org/index.htm is highly regarded and often referenced.
Most people consider the 3 "core" books to be the ideal minimum to have, as the DMG has rules for environments, advancement, traps, dungeons, cities, and treasures; and the Monster Manual had a list of ready made monsters, which are both quite handy, if not strictly needed.
It is also entirely possible to play with only the 3rd edition Player's Handbook, and referencing 5th ed material. Some conversion on the fly will be necessary, and it will be challenging and require more work, but it can be done.
After all, this is a game of imagination, and Gygax himself once commented (and I paraphrase) that if everyone figured out that they could just make up their own rules, they would be out of a job. You don't actually need any books to play, just a set of rules that everyone can agree to. 7