The first one does converge, actually. The catch is that if an integral does not converge absolutely, it doesn't mean it is not convergent.
The integration by parts technique is one way to show that it actually is convergent! To understand intuitively why it is so, it is helpful to look at the graph of $f(x) = (\cos x){(1+x)}^{-1}$:
As you can see, the function is alternating between positive and negative values. As the Riemann integral takes into account the sign of the function, all these areas will cancel out each other. In this case, the result is approximately $0.343378$, and that's because the area between the function and the $x$ axis is progressively smaller and smaller.
Conversely, being $|f(x)|$ non-negative, if you integrate it you will be summing all those areas, which are all positive, and the sum does not converge because its general term is asymptotically equivalent to $1/x$, whose sum diverges.
In general, it can be proved that the Riemann integral has the property
$$\left | \int_a^b f(x)\,\mathrm dx \right | \leq \int_a^b \left | f(x) \right |\,\mathrm dx$$
and it can be extended to improper integrals as well.