For this post, let $X$ be a genus $g$ Riemann surface and $G$ a compact Lie Group. Recently I've been thinking about the nice three-way correspondence between:
(I) Representations of the fundamental group $\pi_{1}(X)$ in $G$ modulo conjugations
(II) Flat principal $G$-bundles on $X$ modulo action by the gauge group, and finally...
(III) Stable holomorphic vector bundles of degree 0, rank equal to rank of $G$, and structure group $G^{\mathbb{C}}$.
The connection between (I) and (II) is very well-known and straightforward using holonomy. In particular, it's clear where exactly we use the flatness of the $G$-bundle to construct a representation: you need flatness to ensure that your choice of path in $X$ depends only on its class in the fundamental group.
I also roughly understand how to get from (I) to (III). Through the "deck transformations" $\pi_{1}(X)$ natrually acts on the universal cover $\widetilde{X}$ of $X$. We can then associate to a representation $\rho: \pi_{1}(X) \to G$ the space,
$$E_{\rho} = \widetilde{X} \times \mathbb{C}^{r} / \pi_{1}(X)$$
where we quotient by the diagonal action of the fundamental group. This is apparently a holomorphic vector bundle and the Narasimhan-Seshadri Theorem shows that the bundles you get this way are essentially the stable ones, modulo a few details.
So my question is, if one wanted to go from (II) to (III) where does the flatness come in? In other words, given a principal $G$-bundle with a flat connection, I'm guessing we just carry out the usual associated vector bundle construction to get an associated holomorphic vector bundle. But I can't see where the flatness comes in. Maybe the flatness is only obviously necessary when you "factor" through the fundamental group representations?