NY has similar provisions, as section 201-D of the labor law specifically prohibits discrimination based on cannabis usage, with exceptions.
Exceptions generally are for businesses that receive federal funding, CDL drivers in accordance with 49 CFR Part 382, and non-employees (contractors, students, volunteers).
I would say the warranty is probably confidence that a percentage will last that long, and the amount they have to replace is cheaper than the business they lose not offering it.
edit: and no argument that companies are also working to make devices less repairable, i’m cynical that more often then not they are trying to design devices that last exactly as long as the warranty.