Hi here is a proof inspired from the reference below. Feel free to get very technical with your comments so that at the end I understand it well. I am more concerned about the questions I added below, so if you want feel free to go straight in answering the questions.
Morse function is generic in $C^{\infty}M$,where M is compact smooth manifold.
Proof:
Step 1
Given any smooth f on M we have:
By compactness $\exists$ finitely many coordinate charts $ \{V_{p}\ ,\ \phi_{p}\}$,$M\subset \bigcup_{k=1}^{N}V_{k}$ with coordinates $x_{p,1},...,x_{p,m}\ $.
Define $\Phi: \mathbb{R}^{N\cdot m}\times M\ni (\lambda_{p,i},x) \mapsto f(x)+\sum_{p}\sum_{i=1,...,m}\lambda_{p,i}x_{p,i}(x)\cdot \phi_{p}(x) \in \mathbb{R}$
$\Rightarrow d\Phi:\mathbb{R}^{N\cdot m}\times M\to T^{*}M$, $d\Phi(\lambda_{p,i},x)=df(x)+\sum_{p,i=1,...,m}\lambda_{p,i}dl_{p,i}(x)$.
Step 2
We will show that $d\Phi\pitchfork 0_{M}$ and so we can approximate f by a Morse function.
Any $x\in M$ is contained in some $V_{p_{x}}$ and so setting $\lambda_{p,i}=0 ~\forall ~p\neq p_{x}$ we get:
$df+\sum_{i=1,...,m} \lambda_{p_{x},i}dx_{i} \Rightarrow$ by varying $\lambda_{p_{x},i}$, we get
span$(x,\{df+\sum_{i=1,...,m} \lambda_{p_{x},i}dx^{i}\})=\{x\} \times T_{x}^{*}M $
$\stackrel{0_{M}~const.}{\Rightarrow} T(T_{x}^{*}M) =\{x\}\times T_{x}^{*}M+T_{x}^{*}M\times \{x\}=T_{x}(d\Phi_{x})+T_{x}(0_{M})\stackrel{P.~Tran.(*)}{\Rightarrow}$
$d\Phi_{\lambda}\pitchfork 0_{M} $ ~ a.e. $\stackrel{\lambda\to 0}{\Rightarrow}f(x)+\sum_{p,i=1,...,m}\lambda_{p,i}l_{p,i}(x)\pitchfork 0_{M}$ $ \square$
(*) By P.Trans., I mean the following lemma:
If smooth $F:M\times S\to N$ has $F\pitchfork Z\subset N$,then $f_{s}\pitchfork Z$,where $f_{s} (x)= F(x,s):M\to N ~$ for a.e. s.
$\textbf{Questions}$: Is $\Phi$ well-defined in the intersections of charts i.e. $V_{p}\cap V_{p'}$ ? Is the arguement "by varying... we get span" missing something? If yes,can you please tell me what?
Thank you so much
proof from http://www.math.toronto.edu/mgualt/Morse%20Theory/Notes5-8.pdf