Every year, there are thousands of grants given to non-profit organisations and individuals for a wide variety of projects in the public interest. Among those projects funded are writing projects for publication as books. In general, government agencies and foundations do not fund individuals. The exceptions are those projects by writers, historians, poets, scientists or others who produce works of value to the public. It sounds like we're saying you can get a grant to write a book. On the face of it, that's true, but there are a whole lot of conditions attached to this kind of funding.
Why grant funders fund books
Grant makers, whether government agencies or private foundations, are interested in funding projects of benefit to the general public. If your project is something of value to society or meets a targeted need that has been identified by the funder as important and you convince the funder that you have the experience and ability to pull it off, you might be able to land a grant of financial support for the writing process.
Who funds book publishing projects
A variety of funders invest in works of literary significance. The two primary federal agencies that do this are the National Endowment for the Humanities and the National Endowment for the Arts. State arts and historical preservation councils also occasionally fund artist or writer-in-residence programs or specific book projects. Private foundations may have, as one of their goals, to support literature or artists or other projects that may take the form of a writing project. You'll have to do a serious search and get to know what the foundations like to fund.
Not just anyone can get a grant to publish a book. To convince a grant maker to pay you to write and/or publish a book, you have to do three things. First, you have to convince them you actually can write and produce a book. You'll need to show books you've actually written and/or published. You'll have to produce writing samples and a vitae showing a history of successfully writing and publishing works.
Second, you'll have to convince them that the project is worth writing. You'll need to show a chapter outline, a description of the content and successfully argue that the book is important to write, that it's timely and worthwhile, but is not commercially viable for whatever reason.
Finally, you will have to convince them that the project meets the funder's grant-making goals. This means that if you'll be writing about an historical event that happened in South Carolina, you'll need to find a foundation with an interest in preserving South Carolina history.
National Endowment for the Humanities
National Endowment for the Humanities supports research, education, preservation and public programs in the humanities. The broad category of "humanities" includes modern and classical literature, art theory, criticism, history, linguistics, humanistic social sciences, comparative religion, law, ethics and philosophy. The NEH has funded 15 Pulitzer Prize winning books, a film documentary on the Civil War, baseball and other historical subjects and thousands of museum exhibits, historical and archaeological studies and special editions of classic books. Visit the NEH website and spend several days exploring. Sign up on the website for their newsletter and bulletins so you'll be notified when they add new material so you can stay aware of any new programmes they are looking to fund
National Endowment for the Arts
The NEA's mission is to "support excellence in the arts, both new and established; bringing the arts to all Americans; and providing leadership in arts education." The NEA supports literary book projects by important authors and poets. They only work with folks who have an established track record or writers from targeted groups whom NEA wants to encourage to produce important works of written art. What neither NEA or NEH or any private foundations will fund is for an inexperienced would-be book author with a nebulous book idea to write the Great American Novel.
If you are paid to write a book, the book may not belong to you. Often these works are released in special editions or provided to educational institutions, libraries, researchers or other public information resource by the funder. Royalties may or may not be given to the author since the funding was up front. You will have to understand the conditions of the grant before it is funded.