It would probably be legal with digital copies; it's just that book publishers have been very zealous in preventing the existence of a market for used digital books.
Copyright has been very silly in the digital realm from the beginning and is unlikely to get less unhinged from reality absent a major overhaul that makes it completely unrecognizable.
Digital media, in particular its resale, is the one good use case for blockchains that no one seems to be interested in (and don't provide me a link of some obscure project working on it; what can I buy with it?). Probably because it's useful for consumers but not for making money.
Copyright has been very silly in the digital realm from the beginning and is unlikely to get less unhinged from reality absent a major overhaul that makes it completely unrecognizable.