Why does the condition of a function being differentiable always require an open domain? Going through Spivak's Calculus on Manifolds and in his definition of a differentiable function from a subset $A$ of $\mathbb{R}^n$ to $\mathbb{R}^m$, $f$ is said to be differentiable if it can be extended to a differentiable function on an open set containing $A$. 
Why is this? So we dont have to worry about taking limits at boundary points? Why is that even a problem? If thats not the problem, what is wrong with defining $f$ to be differentiable on $A$ if it is differentiable at each point in $A$?
 A: Short answer: the requirement of the domain set to be open is not needed to define differentiability. A longer answer follows.
Topological spaces and normed spaces
Let $V$ and $W$ be normed spaces over $\mathbb{R}$. The norms induce the metric topologies on $V$ and $W$, and so $V$ and $W$ are also topological spaces.
Let $E \subset V$. Then $E$ is a topological space which carries the subspace topology inherited from $V$, called a topological subspace of $V$. It is important to note that $E$ is a topological space in itself, and therefore you can never fall off from $E$. To be precise, every open neighborhood of a point $a \in E$ is a subset of $E$. These open neighborhoods are exactly the intersections of open sets of $V$ with $E$, by the definition of a subspace topology. Since $E \subset V$, it can be tempting for intuition to view it from the outside as being embedded in $V$. However, a better intuition is obtained by imagining living in $E$; there is no way out of $E$ by neighborhoods.
The domain need not be open
A function $f : E \to W$ is differentiable at $p \in E$, if there exists a linear function $(D_p f) : V \to W$ such that 
$$
\frac{f(x) - (f(p) + (D_p f)(x - p))}{\lVert x - p \rVert}
$$
has a limit at $p$ equal to zero. Recall that a limit in a topological space is defined using open neighborhoods, so that again there is no way to somehow fall off from $E$. 
We conclude that the definition of differentiability does not require $E$ to be an open set in $V$. 
What if $E = \{0\}$, say? Then - by the definition of a limit - every element of $W$ is vacuously a limit. In particular, zero is a limit, and therefore $f$ is differentiable on $E$. The derivative at a singular set is whatever you want it to be. 
Footnote 1: To avoid confusion, note that $E$ is an open set in $E$, by the definition of subspace topology. This is not the same as $E$ being open in $V$.
Footnote 2: A limit in a singular set shows that the limit is not always unique even in Hausdorff topological spaces.
Footnote 3: The same discussion holds for other forms of differentiation, such as directional derivatives.
An interesting example
This example is adapted from this question. Let $f : \mathbb{R} \to \mathbb{R}$ be differentiable at $0$. Let $E = \{0\} \cup \{1 / n\}_{n \in \mathbb{N}^{>0}}$. Then $(f|E)$ is differentiable at $0$, and $f'(0) = (f|E)'(0)$. Every point in $E$, except $0$, is isolated. The $0$ is an accumulation point.
Another example
Let $f : \mathbb{R}^n \to \mathbb{R}^m$ be differentiable. Then $(f|\mathbb{Q}^n)$ is differentiable, and $f'(x) = (f|\mathbb{Q}^n)'(x)$, for all $x \in \mathbb{Q}^n$. 
An open domain is sufficient for locality
Why would anyone require the domain set $E$ to be open? One answer is locality.
Let $\mathbb{R}$ be equipped with any norm. Since all norms in a finite-dimensional vector space are equivalent, this norm generates the Euclidean topology. Let $E = \{x \in \mathbb{R} : x \geq 0\}$, and $f : \mathbb{R} \to \mathbb{R}$ be such that
$$
f(x) = 
\begin{cases}
1, & x \in E, \\
0, & x \in X \setminus E.
\end{cases}
$$
Then $(f|E)$ is differentiable, and $(f|(X \setminus E))$ is differentiable, but $f$ is not differentiable, or even continuous. To be able to state that $f$ is differentiable - a synthesis of localized analyses - we need a theorem which allows to glue differentiable functions together to form a differentiable function, under some conditions. 
A sufficient condition for such locality is for the domains of the functions to be open, and the functions to agree on value on the overlaps. However, this condition is not necessary for locality. Consider a constant function $f$, and its restrictions to $E$ and $(X \setminus E) \cup \{0\}$. The sets $E$ and $(X \setminus E) \cup \{0\}$ are both non-open sets, $(f|E)$ and $(f|((X \setminus E) \cup \{0\}))$ are differentiable, and $f$ is differentiable.
Footnote 4: The gluing lemma for differentiable functions is in analogue to the gluing (pasting) lemma for continuous functions.
Open questions
Is locality the only reason for some requiring the domain to be an open set? What is a necessary and sufficient condition for the domains sets for the gluing lemma to hold for differentiable functions?
A: The problem is that our definition of differentiability at a point requires the function to be defined on an open neighborhood of that point. So technically, we don't even know what it means for a function to be differentiable at a boundary point.
Right now, we don't have any information about the set $A \subseteq \mathbb{R}^n$, which is problematic. Naturally, we might want to define $f:A \to \mathbb{R}^m$ to be differentiable at $x \in A$ if there is some linear transformation $Df_x$ such that for all $h$ where $x+h \in A$,
$$\lim_{h \to 0} \frac{f(x+h) - (f(x)+Df_x (h))}{h} = 0.$$
But this definition is problematic when $A$ is not an $n$-dimensional manifold. For example, take $$f(x,y) = \frac{xy^2}{x^2+y^2}$$ (with $f(0,0)=0$). We don't consider $f$ to be differentiable at the origin. But if $A$ is any line through the origin, we will find (with our putative definition above) that $f$ is now differentiable at the origin, when we probably don't want to consider that to be the case.
Now, if $A$ were an $n$-manifold, then our idea for defining the derivative of the function on the boundary will work, because locally at the boundary point, the boundary of $A$ looks like a plane cutting through the boundary point, and so we "see half the space," and the definition above would be equivalent to $f$ being able to be differentiably extended to an open set containing $A$.
A: Here is a motivating example. Say we have $f:[0,1)\rightarrow \mathbb{R}$.  When should we call $f$ differentiable on $[0,1)$?
In particular, how should we determine if $f$ is differentiable at $0$?  Even if we have that $f$ is differentiable on $(0,1)$, and that $$\lim_{h\rightarrow 0^+}\frac{f(h)-f(0)}{h}$$ exists, we have no way of determining anything about $$\lim_{h\rightarrow 0^-}\frac{f(h)-f(0)}{h}$$ since $f(x)$ is not defined for $x<0$.  
We could simply say that $f$ is differentiable on $[0,1)$ if it is differentiable on $(0,1)$ and right differentiable at $0$.  However, then if we took, for example, $f(x)=|x|$, we would find that $f$ is not differentiable at $0$ with domain $(-1,1)$ (or any open interval containing $[0,1)$), and yet $f$ is differentiable at $0$ on $[0,1)$.  Intuitively, $f$ should be differentiable at $0$ either all the time or never, rather than only sometimes, so this would not be a very good definition.
Instead, we simply insist that $0$ be differentiable in the usual way at $x=0$, which requires $f$ be defined on an open neighborhood around $0$. 
You can see where this is going. In general, if $f$ has domain $\mathcal{D}$, we want to call $f$ differentiable whenever $f$ is differentiable at every $d\in\mathcal{D}$, which requires that we can extend $f$ to include open neighborhoods around every $d$.
