example of random variable that is integrable but have infinite second moment
Suppose $\Pr(X>x) = \dfrac 1 {x^\alpha}$ for $x\ge 1$.
Then $f_X(x) = \alpha x^{-\alpha-1}$ for $x\ge 1$.
So $\operatorname{E}(X) = \dfrac \alpha {1-\alpha}$ if $\alpha>1$.
And $\operatorname{E}(X^2) = \dfrac \alpha {2-\alpha}$ if $\alpha>2$.
If $1<\alpha<2$ then $\operatorname{E}(X)<\infty$ and $\operatorname{E}(X^2) = \infty.$
Now let's try a similar one with integer values in the set $\{1,2,3,\ldots\}$.
$$ \text{Let } \zeta(\alpha) = \sum_{n=1}^\infty n^{-\alpha}. $$
$$ \Pr(X=n) = \dfrac{n^{-\alpha}}{\zeta(\alpha)}.$$
(This is sometimes called a Zipf distribution, after George Kingsley Zipf.)
As above, $\operatorname{E}(X)<\infty$ if $\alpha>2$ and $\operatorname{E}(X^2) = \infty$ if $\alpha>3$.