Theorem. A compact interval $[a,b]$ is connected.
Suppose $[a,b]$ were disconnected. Then there would exist a continuous surjective function $f$ from $[a,b]$ onto the discrete space $\{0,1\}$. Said discrete space can also be considered as a subset of $\mathbb R$ with the subspace topology, so $f$ would be continuous as a function from $[a,b]$ to $\mathbb R$ as well. But by the intermediate value theorem, it would attain every value in the interval $[0,1]$ contradicting that it's a function onto $\{0,1\}$. Hence such a function cannot exist, and $[a,b]$ must be connected. $\square$
Theorem. If a space $X$ contains at least two points and any pair of distinct points of $X$ are contained in a connected subset, then $X$ is connected.
Proof. Suppose we have disjoint nonempty open sets $A,B \subset X$ with $A \cup B = X$, i.e. a disconnection of $X$. By the assumption there are $a \in A$ and $b \in B$ contained in a connected $S \subseteq X$. $S$ has the subspace topology, so $A \cap S$ and $B \cap S$ would then be disjoint nonempty open subsets of $S$ with $(A \cap S) \cup (B \cap S) = (A \cup B) \cap S = X \cap S = S$, yielding a disconnection of $S$, which is our desired contradiction. $\square$
Corollary. $\mathbb{R}$ is connected.