I think when you purchase an actual book there should be a code in the back for a digital copy so one doesn't need to repurchase it on a device.
This is an issue that has be brought up a fair bit and addressed in much more depth than I've got time to address, but here's the tl;dr:
D&D Beyond and Wotc are two different companies; company A cannot sell a product belonging to company B without an arrangement.
Cost; adding codes would drive up the cost for consumers.
Partnership fairness; WotC has various agreements with services to license distribution; D&D Beyond, Fantasy Grounds, roll20. If WotC started passing on the cost of a DDB code, they'd have to also include a roll20 code and an FG code
Security; codes are a very insecure method and can cause a lot of losses for someone
Cost of security; it's possible to secure codes by putting them through a point of sale system, but this passes on costs to the stores selling the book
Older users; this would suck for those who've already bought the books and be fairly disenfranchising
I think when you purchase an actual book there should be a code in the back for a digital copy so one doesn't need to repurchase it on a device.
This is an issue that has be brought up a fair bit and addressed in much more depth than I've got time to address, but here's the tl;dr:
Find my D&D Beyond articles here