I'm probably missing something obvious, but I've been wondering what the motivation is for requiring the components $A_\mu$ in a local trivialization of a gauge connection on a smooth principal $G$bundle to lie in $\mathfrak{g}$, the Lie algebra of $G$. I can see that this gives a couple of nice properties; for example, in a local trivialization it ensures that under a gauge transformation $A'_\mu=gA_\mu g^{1}+g\partial_\mu g$ lies in $\mathfrak{g}$, and that the curvature form $F=dA+A\wedge A$ lies in $\mathfrak{g}$ (since $\mathfrak{g}$ is closed under the Lie bracket). But is there a more intrinsic or geometric reason that $A_\mu$ must be in $\mathfrak{g}$? Thanks.

First, I never liked working with principal bundles; vector bundles seem easier and more natural to me. Second, I never like thinking about abstract principal $G$bundles. I prefer fixing a representation of $G$ and viewing the principal $G$ bundle as a reduced frame bundle associated with a vector bundle. So let $E$ be a rank $k$ vector bundle and $F$ the bundle of arbitrary frames in $E$ (this is a principal $GL(k)$bundle). Then $GL(k)$ acts on the right on $F$. Given a subgroup $G$ in $GL(k)$, let $F_G$ be a subbundle of $F$ such that if $f \in F_G$, then so is $f\cdot g$ for each $g \in G$. The primary example is $E = T_*M$ and $F_G$ is the bundle of orthonormal bases of the tangent space with respect to a Riemannian metric. What is the critical property we want a $G$connection to satisfy? Well, any connection allows you to parallel translate an arbitrary frame $f \in F$ along a curve. We'd like the $G$connection to be such that if $f \in F_G$, then the parallel translation remains in $F_G$. This leads to the right definition of a $G$connection. 


I always find it helpful to think about Cartan geometries first  they are less "abstract" than principal bundles and shed new light on things like Riemannian geometry. 


As Mariano points out in his comment, this follows from the definition of a connection on a principle $G$bundle $\pi: P \to M$. At every $p \in P$, the kernel of $\pi_* : T_pP \to T_{\pi(p)}M$ defines the vertical subspace of $T_pP$. Let's call it $V_p$. It is spanned by the fundamental vector fields of the $G$action on $P$. Since this action is free, the fibres are principal homogeneous spaces and hence $V_p$ is isomorphic to the Lie algebra $\mathfrak{g}$. A connection (à la Ehresmann) is an equivariant choice of horizontal subspace $H_p$ complementary to $V_p$. Hence it can be defined as the kernel of a 1form $\theta$ with values in the adjoint representation of $G$ (from equivariance of the horizontal subspace). The gauge field in your question is then the pullback via a local section of that connection 1form. Hence locally it is a 1form on $M$ with values in the Lie algebra $\mathfrak{g}$. So the reason the gauge field is $\mathfrak{g}$valued is the equivariance of the of the connection (in the sense of Ehresmann). If you then ask why one imposes equivariance, one answer is that it is the natural condition in this context, but perhaps someone else has a more convincing reason. 


I'm not sure about the mathematical origins, but the original physical motivation was Yang and Mills's attempt to deal with the approximate SU(2)symmetry of nucleons (protons and neutrons). The big step was (as I understand it) when GellMann (and Ne'eman, independently at about the same time) realized that a diagram labeling experimentally observed particles was the weight diagram for SU(3). He made some predictions at a conference:
and the rest was the eightfold way. Of course, principal $G$bundles and the connections on them had been around for quite some time before (Simons famously pointed this fact out to Yang later on). 

