There are two main classes of stacks, Deligne-Mumford stacks (DM stacks) and Artin stacks. The initial construction requires a category fibered in groupoids (CFG), and adds two conditions
a requirement for extending diagrams via cartesian squares, and
Algebraic varieties are one of the central objects of study in classical (and to some extent, modern) algebraic geometry.
Historically, the fundamental theorem of algebra established a link between algebra and geometry by saying that a polynomial in one variable over the complex numbers is determined by the set of its roots, which is an inherently geometric object.
An abstract algebraic variety is a particular kind of scheme; the generalization to schemes on the geometric side enables an extension of the correspondence described above to a wider class of rings.
In algebraic geometry, an algebraicstack is a concept introduced to generalize algebraic varieties, schemes, and algebraic spaces.
The moduli space of algebraic curves (Deligne-Mumford stack) defined as a universal family of curves of given genus g does not exist as an algebraic variety because in particular there are elliptic curves admitting nontrivial automorphisms.
For elliptic curves over the complex numbers the corresponding stack is a geometrical factor of the upper half-plane by the action of the modular group.