Since you are allowed to multiply the function with $(z-1)^n(z+1)^m$ with $n,m\in\mathbb N$, we may assume that $a,b>1$.
Consider $z=re^{i\phi}$ with $r$ big.
Then $(z-1)^a(z+1)^b= r^{a+b}e^{(a+b)i\phi}\left(1+O(\frac1r)\right)+C$. For this to "close" if we fix big $r$ and let $\phi$ change from $0$ to $2\pi$, we need that $(a+b)$ is an integer. More precisely, we have
$$\begin{align}0&=r^{a+b}e^{(a+b)i\cdot2\pi}\left(1+O(1/r)\right)-r^{a+b}e^{(a+b)i\cdot0}\left(1+O(1/r)\right)\\
&=r^{a+b}(e^{(a+b)i\cdot2\pi}-1+O(1/r)) \end{align}$$
i.e.
$$e^{(a+b)i\cdot2\pi}-1=O(1/r),$$
hence $e^{(a+b)i\cdot2\pi}=1$.