Calculate $\int_{-\infty}^{+\infty}\frac{x}{1+x^2}dx$, what is wrong with this?
The point is that, for this improper integral to exist (in the Riemann sense), you would need to prove that the limits $$ \lim_{M,N\to+\infty}\int_{-N}^{M}\frac{x}{1+x^2}dx $$ exist separately in $M$ and $N$. However, this is false because $$ \int_{-N}^M \frac{x}{1+x^2}dx=\frac{1}{2}\log\frac{1+M^2}{1+N^2}\xrightarrow[M\to+\infty]{N=\text{ fixed}}+\infty. $$ For the integral to exist in the Lebesgue sense, you need to have first control on the positive and negative parts separately, i.e. $$ \int_{\mathbb R}\frac{x}{1+x^2}dx=\left[\,\int_{\mathbb R_-}\frac{x}{1+x^2}dx\right]+\left[\,\int_{\mathbb R_+}\frac{x}{1+x^2}dx\right] $$ if both square brackets exist separately. Again this is not true.
What is correct, and is the content of your statement, is the fact that $$ \lim_{M\to+\infty}\int_{-M}^{+M}\frac{x}{1+x^2}dx=0 $$ as you proved. This is commonly defined as the Cauchy Principal Value $\mathrm{PV}$ of the otherwise singular integral: summing up $$ \mathrm{PV}\int_{-\infty}^{+\infty}\frac{x}{1+x^2}dx=\lim_{M\to+\infty}\int_{-M}^{+M}\frac{x}{1+x^2}dx=0. $$
We could have also declared, albeit less symmetrically, for any $\lambda > 0$ that $$\int_{-\infty}^{\infty} \frac{x \,dx}{x^2 + 1} = \lim_{a \to \infty} \int_{-a}^{\lambda a} \frac{x \,dx}{x^2 + 1},$$ and evaluating this limit gives $$\lim_{a \to \infty} \left.\frac{1}{2} \log (x^2 + 1)\right\vert_{-a}^{\lambda a} = \lim_{a \to \infty} \frac{1}{2} \log\left(\frac{\lambda^2 a^2 + 1}{a^2 + 1}\right) = \log \lambda .$$ In particular, by choosing $\lambda$ appropriately, we can make the limit take any real value we want!
To avoid this situation categorically, we usually restrict our attention to improper integrals for which the value does not depend on the relative rate at which we "exhaust" the integrand in the leftward and rightward directions. We formalize this situation by defining an integral of the form $$\int_{-\infty}^{\infty} g(x) \,dx$$ to be the sum $$\int_{-\infty}^a g(x) \,dx + \int_a^{\infty} g(x) \,dx ,$$ provided that both of the constituent improper integrals exist, so that one only deals with one limit at a time. (It is straightforward to verify that if this value exists, it is independent of $a$.)
Now, in some circumstances, one wants to assign a value to an integral $\int_{-\infty}^{\infty} g(x) \,dx$ for which the above definition does not give a value, because one or both of the summands does not converge. In this case, one can define the Cauchy Principal Value as the limit of the integrals over intervals symmetric about the origin, that is, as $$PV \int_{-\infty}^{\infty} g(x) \,dx := \lim_{a \to \infty} \int_{-a}^a g(x) \,dx ,$$ and for odd $g$ this limit is always zero. But as your example shows, this notion does not in general coincide with the usual notion of improper integral.