Briefly, this works very nicely when $X$ is locally compact, but not otherwise.
Then the function space carries the compact-open topology.

John Isbell gave a survey of the story and literature in his paper
*General Function Spaces, Products and Continuous Lattices*,
in Math Proc Cam Phil Soc **100** (1986) 193--205.

It is an ongoing matter in theoretical computer science.

There is frequent and ongoing literature on this subject going back to
when Ralph Fox introduced the compact-open topology in
*On Topologies for Function-Spaces* in Bull AMS **51** (1945).

It was originally considered in homotopy theory,
then in category theory and topological lattice theory.
After that theoretical computer science took over,
under the headings of domain theory, realisability
and "exact" real computation.

Along the way some very important concepts have been identified,
in particular the **universal property** of the **exponential** in
a **cartesian closed category** (as stated elsewhere on this page)
but also that of a **continuous lattice**.

Briefly, a distributive continuous lattice is exactly the topology
of a locally compact space.

I say this primarily as a warning to those (students in particular)
who may think that a little bit of tweaking of the category or
the universal property might yield better results.
There are a lot of *broken* ideas along the way,
some of which you will find surveyed in Isbell's paper.
Breaking a *correct* idea like the universal property
(by restricting its test object to a single space) is not going to help.

The most important topological space is not the real interval but the
Sierpinski space, for which I write $\Sigma$.
Classically, it has open open and one closed point.
It is important because there are (constructive) bijections amongst

- continuous functions $\phi:X\to\Sigma$,
- open subspaces $U\subset X$ and
- closed subspaces $C\subset X$.

In particular, putting $Y\equiv\Sigma$ in the desired universal
property, a continuous map $\phi:\Gamma\times X\to\Sigma$
is an open subspace of $\Gamma\times X$
and you want that to correspond to a continuous function $\Gamma\to\Sigma^X$.

With $\Gamma\equiv{\bf 1}$, this means that the points of $\Sigma^X$
must be the open subspaces of $X$.

With $\Gamma\equiv\Sigma^X$, we want the transpose of $id:\Sigma^X\to\Sigma^X$
to be continuous, but this is $ev:\Sigma^X\times X\to\Sigma$ defined
by $ev(U,x)\equiv(x\in U)$.
This map defines an open subspace of $\Sigma^X\times X$,
which is a union of rectangles ${\cal V}\times V$.
If $x\in U$ then $(U,x)\in{\cal V}\times V$ and $x\in V\subset K\subset U$
where $K\equiv\bigcap{\cal V}$ is compact.

So this works exactly when $X$ is locally compact and $\Sigma^X$
is its lattice of open subspaces, itself equipped with the
**Scott topology**, which has a basis consisting of
${\cal V}\equiv\lbrace W|K\subset W\rbrace$ for $K$ compact.

I forget why $K$ is compact, but a good place to look would
be the paper
*Local Compactness and Continuous Lattices*
by Karl Hofmann and Mike Mislove
in Springer Lecture Notes in Mathematics **871** (1981) 209-248.
It was in this paper that the **interpolation property**
$x\in V\subset K\subset U$ was introduced
as the **definition of a locally compact space** that is (sober but)
not necessarily Hausdorff.

[**PS:** Peter Johnstone has a neat argument involving preservation of injectivity, in the final chapter of his book *Stone Spaces*.]

So this is the reason why local compactness of $X$ is necessary.

If $X$ is locally compact then the exponentials $Y^X$ exist for *all*
spaces $Y$.
However, even when $Y$ is locally compact, $Y^X$ need not be,
for example **Baire space** $N^N$ is not,
so locally compact spaces do not form a cartesian closed category.
Nevertheless, $\Sigma^X$ is always locally compact when $X$ is.

Of course the argument for necessity above does not work
if you only allow $\Gamma\equiv[0,1]$ in the universal property.
However, it is not a good idea to mess around with such definitions.

If you seriously want to use the collection of maps $X\to Y$
as another space then you require a notation and a way of computing
with **functions as first-class objects**.
This notation is called the (typed) **lambda calculus**.

When the universal property of the exponential was recognised
in the 1960s, it was not only related to this question in general topology
but also to the formulation of symbolic logic,
that is, to the lambda calculus and to **proof theory**.

I always write $\Gamma$ for the test object of a universal property
because it plays exactly the same role in category theory
as the **context** does in symbolic logic,
which is customarily written with this letter.
The context of an expression is the list of parameters (free variables)
in it and their types (the spaces over which they range).

If you restrict $\Gamma$ to be just the singleton or interval
then you cannot have general parameters in your expressions.

Dana Scott initially got involved in this subject because he wanted
to show that the *untyped* lambda calculus is meaningless.
However, he fairly quickly discovered models of it,
in the form of topological lattices such that $X\cong X^X$.
See, for example, his
*Data Types as Lattices* in
the SIAM Journal on Computing **5** (1976) 522-587.

Out of this grew veritable industries called **domain theory**
and **denotational semantics**.
In the 1980s, cartesian closed categories of domains came two-a-penny
(I was responsible for some of them), where
"domains" were particular kinds of partial orders
equipped with the Scott topology.
Denotational semantics used these to give mathematical
meanings to constructs in programming languages
in order to demonstrate the correctness of programs.

If you do not like the story for the whole of the traditional category
of topological spaces then there are many alternatives.

The "official" answer in homotopy theory was
the (full sub)category of **compactly generated spaces**.

On the other hand, there are ways of enlarging the traditional
category to make it cartesian closed.
*Equilogical Spaces and Filter Spaces* by Pino Rosolini
in Rendiconti del Circolo Matematico di Palermo **64** (2000) 157--175
gives an excellent survey of them,
explaining how they are reflective subcategories of
presheaves on the traditional category.
In particular, Scott had introduced **equilogical spaces**,
defined as topological spaces equipped with formal equivalence relations;
the theory is set out in full in
*Equilogical Spaces*
by Andrej Bauer, Lars Birkedal and Dana Scott.

Having gone to the trouble of writing this lengthy account
of (some of) the history of this question,
I would like to turn it back on the homotopy theorists.

When topics like this were considered by categorists in the 1960s,
they aimed their papers at (for example) topologists.
Therefore they did not spell out the topology, because their
intended readers would know it.
This is very frustrating for subsequent students of category theory:
the papers just contain the category theory and it is impossible
to trace back to the preceding mathematical ideas.

So I would be grateful if the homotopy theorists here would explain,
without rehearsing the category theory,
what the motivations were and are in their own subject
for asking for "convenient" or cartesian closed categories.

**PS** Thanks to Tyler Lawson for the comment below answering this question. Is there a slightly more detailed explanation of these methods, say of the length of a MO answer, or a survey paper?

In the context of an application of this kind, the next question is whether the cartesian closed categories that have been used (and mentioned above) are the most appropriate for the job. On the face of it, you're happy with "any old" CCC. But, when you look at the *extra* objects of this category, do the extensions of topological notions to them behave in the way that you would like? That is, according to whatever other intuitions of topology you have, such as developing results along the lines that Tyler mentions?

Many early applications of category theory imported the benefits of "set theory" by working in the Yoneda embedding (presheaves) or a smaller category of sheaves. Rosolini showed (in the paper cited above) how the CCC extensions of categories of topological spaces are subcategories of the Yoneda embedding. There is a close technical analogy in that both kinds of subcategory are reflective, but for sheaves the reflector (left adjoint to inclusion) preserves all finite limits, whereas in these CCCs it preserves products but not all equalisers or pullbacks.

My personal view is that these extensions are not topology but **set theory with topological decoration**. In this context, by "set theory" I mean, not the study of $\in$, but that of discrete spaces, whereas I believe (following Marshall Stone) that mathematical structures should be intrinsically topological. I have a research programme called Equideductive Topology that tries to look at such extensions without importing set theory.

1more comment