Let $M$ be a closed manifold. If $f$ is a Morse function on $M$, then by Morse inequalities we know that $f$ must have at least $\sum_i\beta_i(M;\mathbb{Z}_2)$ critical points. When is it possible to find such a function with exactly this number of critical points? If one can find such a function, then the boundary maps in the Morse complex must be zero. Does there exist any sort of topological property that can prevent from boundary maps being zero?
For instance, on a closed surface, this is possible since if we take a Morse function with only one max point and one min point, then the boundary maps in the Morse complex must be zero and we have $\beta_1(M;\mathbb{Z}_2)$ critical points of index $1$, one with zero index and one with index $2$.