Why does a principal G-bundle with a discrete structure group G have a unique flat connection? I'm reading the Dijkgraaf–Witten paper Topological gauge theories and group cohomology (Comm. Math. Phys. 129 (1990) pp 393–429, doi:10.1007/BF02096988) and on page 395, 2nd paragraph they write

Suppose we choose a discrete group $G$. Every principal $G$-bundle has a unique, flat connection, and corresponds to a homomorphism $\lambda : \pi_1(M) \rightarrow G$

There are two parts to this question: why must such a bundle have a flat connection that's unique? And what exactly is the significance of the second part of the statement (the part about the homomorphism)?  
 A: Let $p:P\rightarrow M$ be a $G$-principal bundle, there exists a good covering $(U_i)$ which is a trivialization of $p$,  the transition functions are defined by $g_{ij}:U_i\cap U_j\rightarrow G$, if $G$ is discrete, $g_{ij}$ is constant. On $U_i\times G$, we can define a distribution tangent to $U_i\times\{g\}, g\in G$ which gives rise to a connection on $P$, this connection is unique since by definition, a connection on $U_i\times G$ is a distribution transverse to the fibres of $U_i\times G\rightarrow U_i$, the dimension of this distribution is $dimM$ and for evry point of $y$ $U_i\times G$ there exists a unique vector subspace of $U_i\times G$ whose dimension is $dimM$ and it is $T_y(U_i\times G)$ since $G$ is discrete, this connection is flat since it is tagent to $U_i\times\{g\}$ which is integrable.
A: Tsemo's answer addresses the first part of your question. To answer the second, for $G$ discrete, a $G$-bundle $p:P\to M$ is in particular a covering space for $M$, and so every path in $M$ has a unique lift (which happens to be the horizontal lift for the flat connection discussed in Tsemo's answer). So a closed path $\gamma:[0,1]\to M$ based at $x\in M$ lifts to the path $\tilde\gamma:[0,1]\to P$ (starting at some fixed $q\in p^{-1}(x)$). Since $\tilde\gamma(0)$ and $\tilde\gamma(1)$ lie in the same fibre, they differ by an element of $G$, so we can write $\tilde\gamma(1) = \tilde\gamma(0)\cdot \Lambda(\gamma)$. In fact, homotopies on $M$ also lift to $P$, and so $\Lambda$ factors through $\pi_1(M)$ to give a map $\lambda:\pi_1(M)\to G$. It is not too hard to show that $\lambda$ is a homomorphism. $\lambda$ essentially defines $P$ (for $M$ connected): if $\tilde M$ denotes the universal cover of $M$, then $P \simeq \tilde{M}\times_\lambda G$.
You can find a nice discussion of covering spaces in Hatcher's Algebraic Topology (particularly Section 1.3, Lifting Properties). The lifting arguments above apply more generally to principal bundles with flat connections (even if $G$ is not discrete): a discussion of flat bundles and holomorphy homorphisms is contained in Section 2.1.4 of Morita's "Geometry of Characteristic Classes".
