Lemon laws exist because, before the late 1970s, buying a new car with a defect that nobody could fix meant you were just stuck with it. California passed the first modern lemon law — the Song-Beverly Consumer Warranty Act — in 1970 and tightened it with the Tanner Consumer Protection Act in 1982. Every other state followed by the early 1990s. The basic deal: if a new vehicle has a substantial defect that the manufacturer can't fix after a reasonable number of attempts, they have to replace it or refund you.
Every state has its own version, with different cutoffs for what qualifies, how many repair attempts you need, and which vehicles are covered. The federal Magnuson-Moss Warranty Act (1975) sits behind all of them as a backup — if a manufacturer doesn't honor a written warranty, you can sue under federal law and recover attorney's fees if you win, which is why most lemon-law lawyers will take your case on contingency.