This is a theorem proved in Munkres.
Let $f:X\to Y$ be a bijective continous function. If X is compact and Y is hausdorff, then f is a homeomorphism.
I knew Y being hausdorff which will be good to imply compact set in Y being closed which will imply continuity for the inverse. I have three questions. They may be related.
What kind of role is Y being hausdorff?
Why it is necessary to be hausdorff?
What is the intuition behind Y being hausdorff?
To generalize Mathmo123's example: since $f$ is bijective we may as well consider $Y$ to be the same set as $X$, but with a weaker topology (i.e. some of the open sets of $X$ are no longer open). Then $f$ is still continuous, but no longer a homeomorphism. So what the theorem is saying is that you can't weaken a compact topology and have it be Hausdorff, and you can't strengthen a Hausdorff topology and have it be compact.