Let $f(x)=x$ and $g(x)=\frac{1}{x}$, Domain$(f)=\mathbb{R}$ and Domain$(g)= \mathbb{R}-\{0\}$. We have to find the domain of $\frac{f(x)}{g(x)}$.
When we solve this expression, as the $x$ of $g(x)$ would go to the numerator, we would get the final term as $x^2$. As $x^2$ is defined for all $\mathbb{R}$, the domain should be $\mathbb{R}$ for $\frac{f(x)}{g(x)}$. Then why do we take the domain as $\mathbb{R}-\{0\}$ instead of $\mathbb{R}$?