Compiler-generated classes are automatically created by the compiler to handle specific programming constructs, such as anonymous classes or data classes, that simplify coding by reducing boilerplate code. They are essential for implementing language features like lambda expressions and pattern matching, ensuring efficient and optimized bytecode generation.