TITLE: Is topology just the minimal mathematical structure you need to define on a set just to define continuous functions?
QUESTION [7 upvotes]: I looked for a lot of explanations for the idea of defining a topology for a set to make a topological space, I found a lot of clever explanations but most of them seem like just "concrete explanations that may seem like the original idea but actually has nothing to do with it", and the worst of them who try to make an analogy between a topological space and a metric space by explaining them with a notation of semi-measures? which I guess has nothing to do with the actual idea behind the topology.
I think "but not quite sure that's why I'm asking" that the core idea of topology is in its definition of continuous functions, like if we take the donut and cup definition of two shapes: two shapes are the same topologically if there is no cuts needed to transform one of them to the other, and put two 2D surfaces in $\mathbb{R}^3$ , it's easy to see that they will satisfy this property if there is a kind of a continuous function and a continuous inverse between them, so in order to generalize that you need a minimal structure to define for sets so that you can define continuous functions, so is that it?
EDIT: It seems that the easiest way to make sense of topologies and there axioms at the beginning of studying the subject is basically through a generalization of continuous functions $f:\mathbb{R}^n\to \mathbb{R}^m$, in the simplest case of them $f:\mathbb{R}\to \mathbb{R}$ we can easily see that a function is continuous everywhere if the preimage of any open interval is also an open interval, if $f$ is discontinuous at some point say $x$ it's easy to see that you can make an open interval containing $f(x)$ but it's preimage will be half closed half open interval so it fails the condition of making the preimage of any open subset open, then the axioms of a topology can be seen as the properties of the set of open intervals, the union of 2 opens is open ...etc, so a topology is a generalization of the set of open intervals so we can define continuous functions for any set with such a structure topological spaces, this intuition seems also to be the direction of Munkres's topology book when he first introduce continuous functions.

REPLY [4 votes]: I like Asvin's answer a lot, but I would like to add an answer of a slightly different flavor.
I see the answer as "yes," because a topology is the minimum amount of structural information about a space that is generally used in mathematics to decide whether a function is continuous.
The definition of "continuous" was probably first given with respect to functions from $\mathbb{R}$ to $\mathbb{R}$ (or subsets thereof), and defined with respect to $\mathbb{R}$'s metric structure, although the definition predated the idea of "$\mathbb{R}$'s metric structure" so nobody would have described it that way. A function $f:\mathbb{R}\rightarrow \mathbb{R}$ is continuous at a point $c\in \mathbb{R}$ if for all $\varepsilon >0$, there exists a $\delta >0$ such that $|x-c|<\delta\Rightarrow |f(x)-f(c)|<\varepsilon$. (Notice that the metric structure of $\mathbb{R}$ is playing the key role here, as $|x-c|$ and $|f(x)-f(c)|$ are both measurements given by the metric.) A function $f:\mathbb{R}\rightarrow\mathbb{R}$ is continuous (no reference to a specific point) if it is continuous at each point $c\in \mathbb{R}$. 
In this context, at some point it was noticed (and proven as a theorem) that $f$ being continuous on all of $\mathbb{R}$ is actually equivalent to the property that for any open set $U\subset\mathbb{R}$, the inverse image $f^{-1}(U)$ is also open. Working out this equivalence (for functions $\mathbb{R}\rightarrow \mathbb{R}$) is a very satisfying exercise.
Once this theorem was articulated and proven, it became possible to make the following profound observation: While the original definition of continuity made explicit use of distances like $|x-c|$ and $|f(x)-f(c)|$, actually it would be possible to determine whether $f:\mathbb{R}\rightarrow\mathbb{R}$ is continuous without being able to access these distances, as long as we still have access to whether or not any given set is open. In other words, the knowledge of which sets are open is enough information to determine continuity. Furthermore, if we changed how distances are measured but in such a way that it didn't change which sets are the open ones (for example by replacing $|x-y|$ with $2|x-y|$ as the distance between $x$ and $y$), it would not change which functions are the continuous ones. To summarize, while it initially appeared that the metric was intrinsically involved in determining if a function was continuous, the above theorem means that really it's just that the metric determines which sets are open, and the collection of open sets is really what determines continuity.
This is what paved the way for the definition of a topology. If knowing which sets are open is really what determines whether functions are continuous, then we can drop the metric from the definition completely and use the conclusion of the above theorem as a definition: if $X,Y$ are any spaces such that I know how to determine whether their subsets are open, then $f:X\rightarrow Y$ is defined to be continuous if for each open $U\subset Y$, the inverse image $f^{-1}(U)$ is open in $X$. Thus the information about which sets are open (i.e., the topology) is really the only info you need to determine continuity.
(I see this as analogous to the progression in learning trigonometry from (a) originally defining $\sin \theta$ as the ratio of certain sides in a right triangle, which only makes sense when $0<\theta<\pi/2$, but then (b) learning as a theorem that this definition of $\sin \theta$ coincides with the $y$-coordinate of a certain point on the unit circle, to finally (c) replacing the ratio of sides definition with this $y$-coordinate of the unit circle point as the definition, so that $\sin\theta$ can be defined even when $\theta$ is not in the interval $(0,\pi/2)$. Similarly, continuity is (a) first defined with respect to a metric, but then (b) it is proven as a theorem that the definition coincides with a criterion based only on open sets, and finally (c) the criterion based on open sets replaces the metric-based definition as the definition, allowing continuity to be defined even when there is no metric, as long as you know which sets are open.)
Let me add a comment relating this train of thought to William Elliot's answer, because it pulls in a somewhat different direction. William Elliot's answer foregrounds limits as the key idea of a topology, whereas this answer, and Asvin's, foreground continuity. I see this difference as essentially one of taste. Limits and continuity are deeply interlinked concepts. Indeed, the classical $\varepsilon$-$\delta$ definitions of the two notions (for functions $\mathbb{R}\rightarrow \mathbb{R}$) look almost identical. One can define either in terms of the other. So while my tendency (per the above) is to view continuity as the fundamental property that a topology abstracts from a metric space, I'm not really arguing against William Elliot's decision to view limits as the key thing being abstracted. It seems to me one can choose which way one prefers to look at it, and develop a complete theory from either starting point.