Examples of categories cofibered in groupoids In Chapter 2 of Lurie's Higher Topos Theory, the first main theorem establishes a connection between categories cofibered in groupoids and left fibrations and asserts the importance of studying left fibrations in $\infty$-category theory. However, I lack understanding of the importance of categories cofibered in groupoids in ordinary category theory. Are there any good examples that illustrate the power of the notion of a category cofibered in groupoids?
 A: Categories (co)fibered in groupoids are used to define stacks
(stacks in groupoids, to be precise),
so any introduction to stacks will do.
For stacks on smooth manifolds, see, for example,

*

*Ieke Moerdijk: Introduction to the language of stacks and gerbes.

For stacks in algebraic geometry, see, for example,

*

*Angelo Vistoli: Notes on Grothendieck topologies, fibered categories and descent theory.

*Martin Olsson: Algebraic Spaces and Stacks.

A: Before getting into high-falutin' stacky considerations, I think there's something much more basic to say.
Let $C$ be a 1-category. There is an equivalence between discrete fibrations over $C$ and functors $C^{op} \to Set$, i.e. presheaves.  Here, "discrete fibration over $C$" is another name for "category fibered in sets over $C$", and the $\infty$-categorical analog is called a "right fibration" by Lurie (or maybe it's "left fibration" -- I get confused). Dually, there is an equivalence between discrete opfibrations over $C$ and functors $C \to Set$, i.e. copresheaves. One direction of this equivalence is usually called the Grothendieck construction, or the category of elements in 1-category theory. The $\infty$-categorical version was re-christened as straightening / unstraightening by Lurie.
That is, fibered categories provide a language which is equivalent to the language of presheaves / copresheaves. The central importance of presheaves to category theory is perhaps more familiar, starting from their role in the Yoneda lemma.

Now, the jump from categories cofibered in sets to categories cofibered in groupoids is essentially the jump from functors $C \to Set$ to functors $C \to Gpd$. Technically, in the world of 1-categories, this is not quite true because $Gpd$ is really a $(2,1)$-category, so talking about functors to the "underlying" $(1,1)$-category is usually a mistake -- such functors are "too strict". As a result, the correct statement is that categories cofibered in groupoids over $C$ are equivalent to pseudofunctors $C \to Gpd$. This equivalence is also referred to as the Grothendieck construction. In $\infty$-categories, we simply don't have a corresponding notion of strict functor here, so the analog of a pseudofunctor is just called a "functor".
In $\infty$-category land, $\infty$-groupoids are playing the role previously played by sets in 1-category land. One manifestation of this is that a set is just a 0-truncated $\infty$-groupoid. But similarly, a groupoid is just a 1-truncated $\infty$-groupoid. So there are things in 1-category land which you have to do with groupoids rather than sets (and some of the other answers contain good examples of this), whereas when you do similar things in $\infty$-category land, you just use $\infty$-groupoids in both roles.
So the moral of this story is that when Lurie talks about the importance of categories (co)fibered in groupoids, an extremely important special case of this is the importance of categories (co)fibered in sets, i.e. the importance of (co)presheaves.

All of this generalizes to categories (co)fibered in categories. In 1-category land, this is the general notion of a Grothendieck fibration / Grothendieck opfibration over $C$. Such things correspond, via the Grothendieck construction, to pseudofunctors $C^{op} \to Cat$ (respectively $C \to Cat$). In $\infty$-category land, this construction is again called straightening / unstraightening by Lurie, and he calls Grothendieck fibrations cartesian fibrations and he calls Grothendieck opfibrations cocartesian fibrations.

The advantage of discrete fiberations over prehseaves of sets is minimal; fibered categoies were introduced by Grothendieck precisely to avoid the annoying technical coherence conditions associated with working with pseudofunctors valued in $Cat$ or $Gpd$. Lurie uses fibrations in a similar way, to avoid having to constantly write down higher coherence data for functors valued on $Gpd_\infty$ or $Cat_\infty$ (after all, in order to get a model for either of these $\infty$-categories, one usually takes a big homotopy coherent nerve of a simplicial category, so writing functors into them is a chore).
