For ordinary functions of one variable, the rule for integration by parts follows immediately from integrating the product rule \begin{eqnarray*} \frac{d}{dx}(fg) &=& \frac{df}{dx}g+f\frac{dg}{dx}\\ \int_a^b\frac{d}{dx}(fg)\, dx &=& \int_a^b\frac{df}{dx}g\, dx + \int_a^b f\frac{dg}{dx}\, dx\\ \left. fg \right\vert_a^b &=& \int_a^b\frac{df}{dx}g\, dx + \int_a^b f\frac{dg}{dx}\, dx \end{eqnarray*} Rearranging, we obtain $$\int_a^b\frac{df}{dx}g\, dx = \left. fg \right\vert_a^b - \int_a^b f\frac{dg}{dx}\, dx$$
In an analogous way, we can obtain a rule for integration by parts for the divergence of a vector field by starting from the product rule for the divergence \begin{eqnarray*} \grad\cdot(f\GG) = (\grad f) \cdot \GG + f \, (\grad\cdot\GG) \end{eqnarray*} Integrating both sides yields \begin{eqnarray*} \int \grad\cdot(f\GG) \,d\tau = \int (\grad f) \cdot \GG \,d\tau + \int f \, (\grad\cdot\GG) \,d\tau \end{eqnarray*} Now use the Divergence Theorem to rewrite the first term, leading to \begin{eqnarray*} \int (f\GG) \cdot d\AA = \int (\grad f) \cdot \GG \,d\tau + \int f \, (\grad\cdot\GG) \,d\tau \end{eqnarray*} which can be rearranged to \begin{eqnarray*} \int f \, (\grad\cdot\GG) \,d\tau = \int (f\GG) \cdot d\AA - \int (\grad f) \cdot \GG \,d\tau \end{eqnarray*} which is the desired integration by parts.