Random numbers use an LCG with fixed seed=42 and Box-Muller transforms, so results are reproducible for any given setting.
Top: blue = target N(0,1), green = proposal q(x), red dashed = threshold t, red shading = tail x>t. Bottom: blue = crude MC estimate, red = IS estimate, green dashed = exact value.
The expectation under the target $p$ can be evaluated with weighted samples from a proposal $q$:
$$I = \mathbb{E}_p[h(X)] = \int h(x)\,p(x)\,dx = \mathbb{E}_q\!\left[h(X)\,\frac{p(X)}{q(X)}\right]$$Drawing $N$ samples $X_i$ from $q$ and using the weights $w(X_i)=p(X_i)/q(X_i)$ gives the importance sampling estimator:
$$\hat I_{\text{IS}} = \frac{1}{N}\sum_{i=1}^{N} h(X_i)\,w(X_i),\quad X_i \sim q$$For the tail probability $P(X>t)$ we take $h(x)=\mathbf 1(x>t)$, $p=\mathcal N(0,1)$, $q=\mathcal N(\mu,\sigma^2)$. The weight becomes
$$w(x)=\frac{\sigma\exp(-x^2/2)}{\exp(-(x-\mu)^2/(2\sigma^2))}$$Choosing $\mu\approx t$ places almost every sample in the tail, and the variance reduction ratio $\operatorname{Var}(\hat I_{\text{MC}})/\operatorname{Var}(\hat I_{\text{IS}})$ ranges from a handful to a thousand.