First, I'll answer your questions. Then, I will provide an overview of why the definition is useful.
An example of a closed but unbounded subset of $\mathbb{R}$ is $\mathbb{R}$ itself. Other examples include $[0, \infty)$, $\{1\} \cup (\infty, 0]$, and many more.
Compactness is useful in all dimensions. Examples of compact sets in higher dimensions include a sphere in 3D space (eg $\{(x, y, z) \mid x^2 + y^2 + z^2 = 1\}$), a disc in 2D space ($\{(x, y) \mid x^2 + y^2 \leq 1\}$, and many others.
Now, for why the definition is useful.
First, the definition "A compact set is a set which is closed and bounded" is actually not the optimal definition. The best definition is:
Let $X$ be any topological space. $X$ is compact if and only if for any family of open sets $\{U_i\}_{i \in I}$, if $X = \bigcup\limits_{i \in I} U_i$, then there are $i_1, i_2, ..., i_n$ such that $X = U_{i_1} \cup U_{i_2} \cup ... \cup U_{i_n}$. This is often expressed as "Every open cover of $X$ has a finite subcover."
Here $\{U_i\}_{i \in I}$ being a "family of open sets" means that for all $i \in I$, $U_i$ is an open subset of $X$.
A second definition:
If $X$ is a topological space and $S \subseteq X$, then $S$ is said to be compact if and only if $S$, equipped with the subspace topology, is also compact.
It turns out that
Theorem (Heine-Borel): A subset $S \subseteq \mathbb{R}^n$ is compact if and only if $S$ is both closed and bounded.
However, in other metric spaces, you can have closed and bounded sets which are not compact. The simplest example here is $\mathbb{N}$ equipped with the so-called "discrete metric" - that is, $d(x, y) = 0$ if $x = y$, $1$ otherwise. Under this metric, $\mathbb{N}$ is closed and bounded. However, $\{\{i\}\}_{i \in \mathbb{N}}$ is an open cover of $\mathbb{N}$ with no finite subcover.
Here's the main theorem about compactness:
Theorem: Suppose $X$ and $Y$ are topological spaces and $f : X \to Y$ is continuous. Suppose $X$ is compact. Then $f(X) = \{f(x) \mid x \in X\}$ is a compact subset of $Y$.
This allows us to prove all kinds of nice theorems.
Extreme Value Theorem: Suppose $X$ is compact and nonempty and $f : X \to \mathbb{R}$ is continuous. Then $f$ achieves a minimum value, and $f$ also achieves a maximum value.
Proof: we see that $f(X)$ is a compact, nonempty subset of $\mathbb{R}$. Therefore, $f(X)$ is closed, bounded, and nonempty. Therefore, $f(X)$ has a minimum element and a maximum element. Thus, $f$ achieves both its minimum and its maximum value.
Going a different direction with compactness, we also have
Uniform Continuity Theorem: Suppose $X$ is a compact metric space, $Y$ is a metric space, and $f : X \to Y$ is continuous. Then $f$ is uniformly continuous.
This is the crucial theorem that allows Riemann integration to function.