Why is homology invariant under deformation retraction/homotopy equivalence? This is pretty basic, but I can't find any answers on this site on this already. I want to know why the homology of two spaces $X$ and $Y$ are the same when $X$ deformation retracts/is homotopy equivalent to $Y$. I would appreciate an intuitive explanation and a formal proof.
Specifically I'm working through Hatcher's Algebraic Topology (chapter 2.1) and by homology, I mean both simplicial and singular homology as defined in Hatcher. 
I also assume this holds for relative and reduced homologies, but if you can explain why that would be great.
 A: Thanks to @Danu for the reference. I will give an outline of the proof in Hatcher:
Claim: A map $f : X \to Y$ induces a homomorphism $f_*: H_n(X) \to H_n(Y)$.
Proof: First, define an induced homomorphism $f_\# : C_n(X) \to C_n(Y)$ by $(\sigma : \Delta^n \to X) \mapsto (f \circ \sigma : \Delta^n \to Y)$. 
Secondly, we claim that $f_* : H_n(X) \to H_n(Y) : [a] \to [f_\#(a)]$ is a homomorphism. We need that $f_\#(a) \in \ker \partial_n$ whenever $a \in \ker \partial_n$ (so the map makes sense) and $f_\#(b) \in \text{Im }\partial_n$ whenever $b \in \text{Im }\partial_n$ (so the map is well defined, independent of the choice of representative $a$). ($\partial$ is the differential function $\partial_n : C_n(X) \to C_{n-1}(X)$ or $\partial_n : C_n(Y) \to C_{n-1}(Y)$.)
We can check $f_\# \partial = \partial f_\#$ by explicit computation and this gives us what we need.
We have two easy results:
1) $(f \circ g)_* = f_* \circ g_*$ and
2) id$_{*X} = \text{id}_{H_n(X)}$ (the induced map of the identity on $X$ is the identity on $H_n(X)$).
Proof of 1): We have $(f \circ g)_\# = f_\# \circ g_\#$ (by associativity of $\circ$) and therefore $(f \circ g)_* = f_* \circ g_*$.
Proof of 2): By definition id$_{\#X}$ is id$_{C_n(X)}$ and so id$_{*X} = \text{id}_{H_n(X)}$.
Theorem: If two maps $f,g : X \to Y$ are homotopic, then they induce the same homomorphism $f_* = g_* : H_n(X) \to H_n(Y)$.
The proof of this is the meat of the problem and is given in Hatcher (p111-113).
Corollary: The maps $f_* : H_n(X) \to H_n(Y)$ induced by a homotopy equivalence $f: X \to Y$ are isomorphisms for all $n$.
Proof: If $f$ is a homotopy equivalence then there is a map $g$ such that $f \circ g$ is homotopy equivalent to id$_Y$ and $g \circ f$ is homotopy equivalent to id$_X$. 
Then, by the theorem, $(g \circ f)_* = id_{*X}$ and $(f \circ g)_* = id_{*Y}$. Using the two easy results, we get $g_* \circ f_* = id_{H_n(X)}$ and $f_* \circ g_* = id_{H_n(Y)}$.
Note that a deformation retraction is a special case of a homotopy equivalence so I've now also shown that homologies are invariant under deformation retraction.
A: Since you ask for a treatment of both simplicial and singular homology, I assume you have nothing against an even more general treatment that proves the required result in the general setting of $Ch(R-mod)$, the category of chain complexes with values in $R$-modules, where homology can be defined. 
Both simplicial and singular homologies are particular instances of this general setting (homologies with coefficients in $R$). 
Moreover, I assume you know what a category and a functor between categories are. I assume nothing beyond this. If it does not fit your background, being the tags of your question you will benefit from learning the basics of category theory.
Below I treat the case of an homotopy equivalence (deformation retract is a special case) and give the main steps (without complete proofs but with enough details).
Step 1.   $H_n$ is a functor.
As you may know, being $C,\, D$ two chain complexes and $f:C\to D$ a chain morphism, $f$ induces a morphism of groups $H_n(f):H_n(C)\to H_n(D)$. One can check that $H_n$ is a functor. Actually it is useful to note that $H_n$ is an additive functor between the categories $Ch(R-mod)$ and $Ab$, meaning that the induced morphism $hom_{Ch(R-mod)}(C,D)\to hom_{Ab}(H_n(C),H_n(D))$ is a morphism of groups, i.e $H_n(f+g)=H_n(f)+H_n(g)$. 
Interlude of definitions.
Def.1 (null homotopic) One says that a chain morphism $f:C\to D$ is null homotopic if there exist morphisms $s_n: C_n\to D_{n+1}$ such that $f_n = s_{n-1}\circ d_n + d_{n+1}\circ s_n$ where $+$ denotes the group law on $hom_{R-mod}(C_n,D_n)$ since the category $R-mod$ is abelian. The morphisms ${s_n}$ are called a chain contraction of $f$.
Def.2 (chain homotopic) Two morphisms $f,g$ from $C$ to $D$ are chain homotopic if $f-g$ is null homotopic.
Def.3 (chain homotopy equivalence) A morphism $f:C\to D$ is a chain homotopy equivalence if there exists $g:D\to C$ such that $g\circ f$ (resp. $f\circ g$) is chain homotopic to $id_C$ (resp. $id_D$).
When $g\circ f = id_C$ one says that $f$ is a deformation retract.
Step.2 (lemma) If $f,g:C\to D$ are chain homotopic then they induce the same morphism from $H_n(C)$ to $H_n(D)$.
Proof. Since $H_n$ is additive, one has $H_n(f-g)=H_n(f)-H_n(g)$, so it suffices to prove that if a chain morphism $f:C\to D$ is null homotopic then $H_n(f)$ is the zero morphism. Let $[x]\in H_n(C)$, one has $d_n(x)=0$, hence $f_n(x)=d_{n+1}(s_n(x))\in B_n(D)$ since $f=d\circ s+s\circ d$, ie $f_n(x)$ is a n-boundary of $D$. Thus $H_n(f)([x]) = [f_n(x)] = 0$, ie $H_n(f)=0$.  
Step.3 By the previous lemma and the functoriality of $H_n$, if $f:C\to D$ is a chain homotopy equivalence then $H_n(f):H_n(C)\to H_n(D)$ is an isomorphism with inverse $H_n(g)$, meaning that $f$ is a quasi-isomorphism. Indeed, one has $id_{H_n(C)}= H_n(id_C)=H_n(g\circ f)= H_n(g)\circ H_n(f)$ and $id_{H_n(D)}= H_n(id_D)=H_n(f\circ g)= H_n(f)\circ H_n(g)$.        
