Optical metasurfaces consist of a 2D arrangement of scatterers, and they control the amplitude, phase, and polarization of an incidence field on demand. Optical metasurfaces are the cornerstone for a future generation of flat optical devices in a wide range of applications. The rapidly growing advances in nanofabrication have made the versatile design and analysis of these ultra-thin surfaces an ever-growing necessity. However, despite their importance, a comprehensive theory to describe the optical response of periodic metasurfaces in closed-form and analytical expressions has not been formulated, and prior attempts were frequently approximate. To close this chapter, we develop a theory that analytically links the properties of the scatterer, from which a periodic metasurface is made, to its optical response via the lattice coupling matrix. The scatterers are represented by their polarizability or T matrix, and our theory works for normal and oblique incidence. We provide explicit expressions for the optical response up to octupolar order in both spherical and Cartesian coordinates. Several examples demonstrate that our analytical tool constitutes a paradigm shift in designing and understanding optical metasurfaces. Novel fully-diffracting metagratings and particleindependent polarization filters are proposed, and novel insights into the response of Huygens' metasurfaces under oblique incidence are provided. Our analytical expressions are a powerful tool for exploring the physics of metasurfaces and designing novel flat optics devices.