Let me expand a bit on what Dave said.

The Yoneda lemma tells us that given an object `X` of a category `C`, the (covariant, contravariant, whatever) functor `h_X : C -> Set`, which sends an object `Y` to the set `Hom(Y,X)`, can be thought of as the "same" as the object X. There are many situations in which we are interested in a functor `F : C -> Set`, and we might like to know whether `F` is isomorphic to `h_M` for some object `M`, because that reduces the study of `F` to the study of a single object `M`. In such a case we say that `F` is represented by `M`. The letter `M` here, suggestively, stands for "moduli".

Example: Given a group `G`, the functor `BG' : Top -> Set` is the functor which sends a topological space `X` to the set of isomorphism classes of principal `G`-bundles over `X`. (You can also do the analogous thing for schemes.)

Example: The functor `M_g' : Sch -> Set` is the functor which sends a scheme `X` to the set of isomorphism classes of flat families of genus `g` curves over `X`.

In both of the above examples, there is no object `M` for which `h_M` is isomorphic to the functor. So this is perhaps not so nice. But, without getting into too many details, there is a natural "fix", namely we can instead consider the functor `BG : Top -> Groupoid` (resp. `M_g : Sch -> Groupoid`) which sends a topological space (resp. a scheme) to the *groupoid* of `G`-bundles (resp. flat families of genus `g` curves). This groupoid has objects `G`-bundles and morphisms isomorphisms of `G`-bundles (resp. the obvious analogous thing). The original set-valued functor is just the composition of this functor with the functor `Groupoid` to  `Set` which takes a groupoid and returns the set of isomorphism classes of objects in the groupoid.

Anyway, despite the fact that the set-valued functors are not so "geometric", since they are not represented by a "geometric" object (topological space and scheme, respectively), the groupoid-valued functors are more "geometric". In the case of `M_g`, the "geometric" structure we get is that of a "Deligne-Mumford stack", which essentially means that we can for practical purposes pretend that it is represented by a scheme with only some slightly "weird" properties. In the case of `BG` (the topological one) you can take a "geometric realization" and recover the classifying space `BG` that we know and love.

Another very important reason for studying groupoids and another very important class of groupoids comes from, as others have already mentioned, group actions. When a group acts on a manifold or a variety, the naive quotient may be badly behaved, for example it may no longer be a manifold (e.g. it might not be smooth, or it might not be Hausdorff) or respectively a variety (or it may not even be clear how to take the quotient at all!), which makes it harder to study geometric properties of the alleged "quotient". However, the groupoid viewpoint allows us to get a better handle on the quotient and its geometry. More precisely, if `G` is a group acting on a space (manifold, scheme, variety, whatever) `X`, then the "correct" quotient is actually the functor `X/G : C -> Groupoid` (where `C` is the category of manifolds, schemes, whatever) which sends an object `Y` to the groupoid of pairs (`G`-bundles `E` over `Y`, `G`-equivariant morphism from the total space of `E` to `X`). The functor `BG` is a special case of this; it's `pt/G`.

There's some further discussion on this sort of stuff at the nLab: 

http://ncatlab.org/nlab/show/moduli+space

http://ncatlab.org/nlab/show/classifying+space