Keller's theorem relates the components of the macroscopic dielectric response of a binary twodimensional composite system with those of the reciprocal system obtained by interchanging its components. We present a derivation of the theorem that, unlike previous ones, does not employ the common assumption that the response function relates an irrotational to a solenoidal field and that is valid for dispersive and dissipative anisotropic systems. We show that the usual statement of Keller's theorem in terms of the conductivity is strictly valid only at zero frequency and we obtain a new generalization for finite frequencies. We develop applications of the theorem to the study of the optical properties of systems such as superlattices, 2D isotropic and anisotropic metamaterials and random media, to test the accuracy of theories and computational schemes, and to increase the accuracy of approximate calculations.