A little confusion about compactness and connectedness This question may be a bit simple or even naive for some people but it indeed confuses me for a long time. Thank you all if you provide any explanation.
I know concepts: compactness means any open cover have finite subcover, which is equivalent to closed and bounded; connectedness means there's no disjoint decomposition by two nonempty open sets. However, I have no idea how they play roles in particular cases. I read many theorems that require compact and connected topology but there's no any mention in their proofs.
The situation occurs frequently, as far as I concern, in differential geometry and multivariable calculus (vector fields). Could anyone explain to me how they involve in mathematics? A few examples are better welcomed.
Please let me give some examples


*

*Why do we consider compact Lie group in differential geometry? What role does compact here play here?

*Why do we require compactness of manifold when we consider de Rham cohomology?
 A: The prototypical examples are:


*

*A continuous real function on a compact subset of the real line attains a maximum. This is Weierstrass's extreme value theorem.

*A continuous real function on a connected subset of the real line attains every value between two values. This is the intermediate value theorem.
In topological terms, these are stated thus:


*

*The image of a continuous function on a compact space is compact.

*The image of a continuous function on a connected space is connected.
What is sometimes confusing is that the prototypical examples are usually both stated for closed intervals and these are exactly the compact connected subsets of the real line.
However, even in the real line, a set may be compact without being connected, as in $[0,1] \cup [2, 3]$, and a set may be connected without being compact, as in $(0,1)$.
A: A classic result in Differential Geometry is that $\mathbb R$ and $\mathbb R^2$ are not homeomorphic. If you take a single point out of $\mathbb R$ you break it into two disconnected pieces. If you take a single point out of $\mathbb R^2$ you still have one connected piece.
If you haven't yet covered homeomorphisms, it doesn't matter, it's a simple way of seeing that the two spaces have a different "type".
None the less, with respect, lhf's answer does cover two fundamental theorems in calculus that show the importance of compactness and connectedness.
Cohomolgy is a pretty vast subject. Open coverings play a significant role. If you can have finite covers then counting the intersections of the covering sets is well defined. There are examples, though, where compactness is not required. Paracompactness enables you to have locally finite combinations of intersecting covering sets.
The aspect of compactness that is often important is completeness which is why we go to a lot of trouble having equivalent definitions of compactness. The unit ball in a separable infinite dimensional Hilbert space is not compact so you have to find special subsets that are compact. The open covering definition is useful but maybe doesn't highlight the main reason why we need it in some contexts.
A: As to why one often cares about compact Lie groups and, more generally, compact spaces, one answer (of many!) is that functions on compact spaces are "well-behaved", in the sense that the function cannot grow without bound and cannot oscillate wildly.
This becomes relevant when one wishes to use analytical tools, such as Hodge-de Rham theory, index theorems, etc., to study properties of the underlying topological space (usually manifold). On a compact manifold ($M$), one needn't worry about the behavior of functions as they tend to infinity: every $C^\infty$ function is bounded and has finite mass, hence is $L^p$ for each $p\in[1,\infty]$. 
For (semisimple) Lie groups in particular, compact Lie groups are very "nice". They admit unit-mass bi-invariant measures ("Haar measure") and every irreducible representation is finite-dimensional. Non-compact Lie groups, on the other hand, have much subtler representation theory. For instance, there is a continuous series of irreducible representations of $SL(2,\mathbb{R})$ acting on $C^\infty(\mathbb{H}^2)$.
