When defining the a connection 1-form $A$ on a principal $G$-bundle we require that $$r^*_gA = Ad_{g^{-1}} \circ A, \quad \forall g \in G.$$ Here $r_g^*$ is the pullback of right multiplication by $g$, denoted $r_g$.
I am having some trouble understanding where this condition comes form or why it is important. Why is the adjoint representation appearing here?
Like I said in the comments, I think the natural starting point is that of a horizontal distribution on $\pi:P\to M$, i.e. $TP=\ker d\pi\oplus\mathcal{H}$. The notion of a principal $G$-bundle $P$ is meant to encode "internal symmetries" (at least, when viewed from the perspective of the standard model for instance), encoded by the group action $r_g:P\to P$. So the natural condition to impose on $\mathcal{H}$ in the presence of such a symmetry, is that $(dr_g)_p\mathcal{H}_p=\mathcal{H}_{r_g(p)}$.
Denote the projection $TP\to\ker\pi$ by $\nu$, and denote by $j_p:G\to P$ the map $g\mapsto r_g(p)$. Then $(dj_p)_e:T_eG=\mathfrak{g}\to (\ker\pi)_p$ is an isomorphism. Given a horizontal distribution, we define a $1$-form $A$ by $A_p=(dj_p)^{-1}\circ\nu:T_pP\to\mathfrak{g}$. Given a $1$-form $A$, we can also define a distribution $\ker A\subset TP$. They are just two ways to represent the same idea.
Theorem: The $1$-form $A$ is $\text{Ad}$-equivariant if and only if the horizontal distribution $\mathcal{H}$ is $r_g$-invariant.
Proof. Suppose the distribution is right-invariant. Suppose $X\in T_pP$. Then $X=X_v+X_h\in \ker d\pi\oplus\mathcal{H}$. We can write $X_v=\eta^\sharp_p$, where $\eta\in\mathfrak{g}$ and $\eta^\sharp$ denotes the associated fundamental vector field on $P$. Then one finds (check the details in the last equality) $$A_p(\eta^\sharp_p)=(dj_p)^{-1}(\nu(\eta^\sharp_p))=(dj_p)^{-1}(\eta^\sharp_p)=\eta$$ Using $dr_g\eta^\sharp=(\text{Ad}_{g^{-1}}\eta)^\sharp$, we get $$A_{pg}((dr_g)_p\eta^\sharp_p)=A_{pg}((\text{Ad}_{g^{-1}}\eta)^\sharp_{pg})=\text{Ad}_{g^{-1}}\eta=\text{Ad}_{g^{-1}}A_p(\eta^\sharp_p)$$ This takes care of the vertical component of $X$. For the horizontal component, one has $A_{pg}((dr_g)_p X_h)=0=\text{Ad}_{g^{-1}}A_p(X_h)$ of course.
That proves one direction. I won't go through the proof of the converse, as you can find it in many texts. The one I used when studying this is called "Differential Geometry: Connections, Curvature and Characteristic Classes" by Loring Tu, and it is an extremely well-written book that I would recommend to anyone trying to learn gauge theory. For a full answer to your question, I refer to proposition 27.13, theorem 28.1 and theorem 28.5 in said book.
As you can see though, the crux of the story is that the fundamental vector field transforms in a way that involves the adjoint representation, i.e. the equality $dr_g\eta^\sharp=(\text{Ad}_{g^{-1}}\eta)^\sharp$. And this is what leads to the $\text{Ad}$-equivariance of the connection $1$-form being equivalent to the invariance of the horizontal distribution.