Monte Carlo method cannot be used This is an example from notes

I don't understand why we should think about the $E(x)$ and $Var(x)$ first?
 A: Edit: I strongly recommend getting a new book to study from because this book is garbage by the looks of it. First off, there is a gross typo: the integral to estimate should be $\int_{-\infty}^\infty xf(x)dx$ as can plainly be seen in the explanation presented. Second, the expectation is NOT infinite, it simply doesn't exist, just like in the case of a Cauchy random variable. 
In its most basic form, MC integration draws random samples $x_i$ such that:
$$\frac{(b-a)}{N}[g(x_1)+\cdots+g(x_N)]\approx \int_{a}^{b} g(x)dx.$$
Here $x_i$ are drawn in $[a,b]$, for example as a uniform distribution. When the interval is infinite, we can truncate it to a finite interval and rely on the tail integrals being small. The last sentence translates to $\int_{-\infty}^ag(x)dx+\int_b^\infty g(x)dx<\infty$. 
Notice that the above expression is precisely $(b-a)E[g(X)]$ where $X$ is drawn from $[a,b]$. Thus you need the expectation to be finite.
When the expectation exists, but the variance doesn't, there is no good way of putting error bars on the MC estimate of the integral. 
So in your case, $g(x)=xf(x)$, and the above methodology fails as the tail integrals of $xf(x)$ are NOT finite.
A: There might be the need for a caveat for the question, in term of what is it that you call Monte Carlo integration.
You want to use Monte Carlo to estimate $\int_{-\infty}^{\infty} f(x) dx$, a quantity we know to be 1. One way to to do this is to find a pdf $g(x)$ such that you can sample from $g$, and then
$$\int_{-\infty}^{\infty} f(x) = \int_{-\infty}^{\infty} \dfrac{f(x)}{g(x)}g(x)dx  = E_g \left[\dfrac{f(x)}{g(x)}  \right].$$
So you can get $N$ numbers from $g$, $x_1, \dots, x_N$, and calculate
$$\dfrac{1}{N}\sum_{i=1}^{N}\dfrac{f(x_i)}{g(x_i)} \approx \int_{-\infty}^{\infty} f(x) .$$
Thus, your choice of $g$ will lead to different estimators. @Alex R. in their answer used the uniform distribution pdf
$$g(x) = \dfrac{1}{b-a} I_{a < x<b}. $$
However, in that case you are sampling from a Uniform distribution from the whole real line, and such a distribution does not exist, thus $g$ cannot be the pdf of a uniform distribution.
I believe there might a typo in the notes, since the following R code seems to suggest that a Monte Carlo estimate of $\int_{-\infty}^{\infty} f(x)$ can be obtained. Here I use $g$ to be the pdf of a $N(0,100)$, where $100$ is the variance.
set.seed(1)
N <- 1e4
f <- function(x)
{
  y <- ifelse(abs(x) > 4, 1/x^2, 1/16)
  return(y)
}
# Draws from g
prop <- rnorm(N, 0, 10)
#Evaluate g(x)
g_prop <- dnorm(prop, 0, 10)
#Evaluate f(x)
f_prop <- f(prop)

mc_est <- sum(f_prop/g_prop)/N
mc_est
[1] 0.9502994

I can probably use a better $g$ to get a better estimate, but it looks like Monte Carlo integration is possible. Maybe the question wanted to say "... estimate the value of $\int_{-\infty}^{\infty} x f(x) dx$". In which case Monte Carlo is not possible since the quantity you want to estimate does not exist.
