Suppose $f(z) = P(z)/Q(z)$ is a rational functions with $P, Q$ being polynomials such that the degree of $Q = m \ge n +2 =$ the degree of $P$. I want to show that $f$ has an antiderivative in $|z|>R>0$ for some real number $R$.
My attempt is to define $g(z) = f(1/z)$. Then we can write $$g(z) = z^{m-n} \frac{a_0 z^n +a_1 z^{n-1} +\cdots + a_n}{b_0z^m + b_1z^{m-1} +\cdots + b_m}.$$
Since $P(z)$ and $Q(z)$ have finitely many zeros, $f(z)$ has finitely many poles. Thus, outside some circle $C_R$ centered at $0$ with radius $R$, $f$ is analytic. To show $f$ is analytic at $\infty$, it suffices to show that $g$ is analytic at $0$. Since $z^{m-n}$ and $\frac{a_0 z^n +a_1 z^{n-1} +\cdots + a_n}{b_0z^m + b_1z^{m-1} +\cdots + b_m}$ are analytic at $0$, $g$, being the product of two analytic functions at $0$, is analytic at $0$. Therefore, $g$ is analytic in $|z|>R$. For any simple closed contour $\gamma$ in $|z|>R$, we then have $\int_\gamma g(z)dz= 0$. Thus $g$ has an antiderivative in $|z|>R$, and $f(z)$ also has an antiderivative there.
Why do we need $m\ge n+2?$ My attempt only needs $m\ge n$.
You seem to be trying for the concept of the residue at $\infty$, but you're getting the details wrong.
We want to show that $\lim_{R\to\infty} \int_{|z|=R}f(z)\,dz=0$. Your argument suggests that we should transform this with the substitution $w=\frac1z$ - but if we do this, we have to follow through with the whole substitution rule, including that $dz=-\frac1{w^2}\,dw$. $$\lim_{R\to\infty}\int_{|z|=R}f(z)\,dz = \lim_{R\to\infty}\int_{|w|=\frac1R}\frac{-1}{w^2}f\left(\frac1w\right)\,dw=\lim_{R\to\infty}\int_{|w|=\frac1R}\frac{-1}{w^2}g(w)\,dw$$ This will be zero if $\frac{g(w)}{w^2}=w^{m-n-2}\frac{a_0w^n+a_1w^{n-1}+\cdots+a_n}{b_0w^m+b_1w^{m-1}+\cdots+b_m}$ is analytic at zero, and that's true if and only if $m-n-2\ge 0$. It's possible to get lucky with a zero residue sometimes for higher powers, but it's not something we can rely on.
You didn't find an antiderivative for $f(z)$, because you didn't transform correctly. Apply the chain rule; if $G$ is an antiderivative for $g$, then the derivative of $G(\frac1z)$ is $\frac{-1}{z^2}g(\frac1z)$. That's not $f(z)$.