While sales of some long-published books are sometimes resurrected by a chance remark or a turn in world events, and a few continue to sell well for years, most books enjoy their highest sales during the few weeks immediately after publication.
Once that first flush of sales has passed, what happens to a book?
It becomes part of the publishers backlist: it will probably have turned a profit for the publisher already and so any further sales will provide a welcome income. If it continues to sell consistently, even in smaller numbers, chances are that it's publisher will keep it in print.
There is a cost to the publisher associated with the book: it isn't free to warehouse the remaining copies, and as numbers dwindle they become harder to locate and store, and more difficult to maintain in a clean, new condition. When the income generated by a title is exceeded by the cost of continuing to sell it, the book is declared out of print and all remaining stocks are disposed of.
Where possible, those remaining stocks are sold as "remaindered books" to the chains which specialise in this trade, like "The Works", in the UK: but if the titles don't have much popular appeal, then the last step for them is the pulping machine.