$(X',\tau')$ is a compactification of $(X,\tau)$ if
- $(X',\tau')$ is compact
- $(X,\tau)$ is a topological subspace of $(X',\tau')$
- $X$ is dense in $X'$.
I was wondering why it is necessary to have the last condition. In my notes, I have written down that the third point is there to prevent 'trivial' compactifications such as $\bar{X}^{(X')}$, i.e. the closure of $X$ in $X'$. However, I don't see how this last one is compact.
So, my main question would be: why are we requiring that $X$ is dense in $X'$?
The space in your example is compact since it is a closed subspace of a compact space and thus itself compact.
The compactification should be universal in some sense i.e. there should be some uniqueness. If you leave out the last condition, consider $(0,1) \subseteq \mathbb{R}$. Then there would be very many different compactifications i.e. any closed and bounded set containing $(0,1)$ However, one would really like it to be $[0,1]$.