Logic behind Integration by Parts I understand how integration by parts is proven using the product rule. I am a bit confused why the two functions can be labeled as f(x) and g'(x) arbitrarily. Is it solely because we are allowed to see a function in whatever way we want and this will give us one kind of integral that is correct? If I misused any terms, please correct me as well.
 A: TL;DR  You can factor the function to be integrated into factors
$f(x)$ and $g'(x)$ arbitrarily (within certain broad limitations)
because the theorem for integration by parts is proved for any
$f$ and $g$ (within a very broad collection of possible functions).
In fact you have many choices for $f$ and $g$, not just the "obvious" choice. The trick is to choose $f$ and $g$ so that the result of applying
integration by parts will actually be helpful to you.
The "obvious" choice may or may not work out in this respect,
depending on what function you have to integrate and how it happens
to be written.

What follows is a long, possibly excessively detailed version of the story summarized above.
It seems to me the confusion over labeling is not in the proof of integration by parts, but in how we actually use integration by parts.
The point of the proof of integration by parts is that there are
many, many pairs of functions $f$ and $g$ for which the method works
(mainly, both functions have to be differentiable over the intervals
on which we will use them).
The proof shows that
$$ \int f(x) g'(x)\, dx = f(x) g(x) - \int g(x) f'(x)\, dx. $$
That is, literally, as long as $f$ and $g$ satisfy the necessary
conditions (which are not very restrictive), the formula above
will be true.
So we really do have a lot of freedom in choosing $f$ and $g$.
The sticky part of integration by parts is in fact that you have too many
choices of $f$ and $g$ to which the formula applies.
So as far as the proof is concerned, $f(x)$ could be $x$,
and $g(x)$ could be $e^x$.
If we suppose that $f$ and $g$ in the formula for integration by parts 
actually are these two specific functions,
then $f'(x) = 1$, $g'(x) = e^x$, and the formula tells us that
\begin{align}
\int xe^x\,dx = \int f(x) g'(x)\, dx &= f(x) g(x) - \int g(x) f'(x)\, dx \\
& = xe^x - \int e^x \,dx \\
& = xe^x - e^x + C. 
\end{align}
But the formula for integration by parts is just as true if
$f(x) = e^x$ and $g(x) = \frac12 x^2$,
in which case $f'(x) = e^x$ and $g'(x) = x$,
and the formula tells us that
\begin{align}
\int xe^x\,dx = \int (e^x)x\,dx
 &=  (e^{x})\left(\frac12 x^2\right)
    - \int \left(\frac12 x^2\right)(e^x)\,dx \\
& = \tfrac12 x^2 e^x - \tfrac12 \int x^2 e^x\,dx.
\end{align}
This is true but not very helpful when it comes to evaluating
$\int xe^x\,dx$. In fact it gives us more useful information about
$\int x^2e^x\,dx$ than about $\int xe^x\,dx$.
Again, the formula for integration by parts is just as true if
$f(x) = xe^{-x}$ and $g(x) = \frac12 e^{2x}$,
in which case $f'(x) = (1-x)e^{-x}$ and $g'(x) = e^{2x}$,
and the formula tells us that
\begin{align}
\int xe^x\,dx = \int (xe^{-x})(e^{2x})\,dx
 &= (xe^{-x})\left(\tfrac12 e^{2x}\right)
     - \int \left(\tfrac12 e^{2x}\right)((1-x)e^{-x})\,dx \\
& = \tfrac12 xe^{x} - \tfrac12\int (1-x)e^{x}\,dx \\
& =\tfrac12 xe^{x} - \tfrac12\int e^x\,dx + \tfrac12\int xe^{x}\,dx \\
& =\tfrac12 xe^{x} - \tfrac12 e^x\,dx + C + \tfrac12\int xe^{x}\,dx. \\
\end{align}
This did not go quite as nicely as before, but if we subtract
$\tfrac12\int xe^{x}\,dx$ from both sides of the equation we get
$$ \tfrac12\int xe^{x}\,dx =\tfrac12 xe^{x} - \tfrac12 e^x\,dx + C,$$
which is (in effect) the same result we got before.
The formula for integration by parts is also true if
$f(x) = x$ and $g(x) = x^2$, in which case $f'(x) = 1$, $g'(x) = 2x$,
and the formula tells us that
$$ \int 2x^2\,dx = \int x (2x)\,dx
 = (x)(x^2) - \int (1)\left(x^2\right)\,dx
 = x^3 - \int x^2\,dx,  $$
also completely true and completely useless to us when we are trying
to figure out $\int xe^x\,dx$ -- nothing in these equations matches up
with $\int xe^x\,dx$ at all.
In summary, the reason we can rewrite $f(x)$ and $g'(x)$ 
as (somewhat) arbitrary functions is because
the basic formula is true for (somewhat) arbitrary functions $f$ and $g$.
The tricky part about applying this technique to a particular integral
such as $\int xe^x\,dx$
is that the formula allows us to choose functions $f$ and $g$ that
work, but do not necessarily solve the integral in the easiest way;
or we can choose $f$ and $g$ so that we end up needing to solve
an integral that is even more difficult than we started with.
In principle, we can choose an $f$ and $g$ that
do not work at all (because $\int f(x)g'(x)\,dx$ turns out not to
be equal to the integral we wanted to solve).
The technique is not wrong if we choose $f$ and $g$ poorly;
we just will not get the result we needed that way.
In the case of $\int xe^x\,dx$,
in fact, we do not set $f(x) = x$ and $g'(x) = e^x$ merely because
$xe^x$ is "obviously" the function $x$ multiplied by the function $e^x$.
The fact that we can factor the function that way and have it work
out so neatly is, in a sense, due to dumb luck; specifically, it is because
we prefer to write $xe^x$ rather than $e^x x$.
If the integral to evaluate had been written 
$\int e^x x\,dx$, it would not be a good idea to factor the integrand
as $(e^x)(x)$ and let $f(x)$ be the left-hand factor;
we already saw what happens if we do that.
