Your question is a bit unclear, since you just showed us a copy from some text, without explaining symbols. But it seems clear that $n$ is the total number of observations of some $d$-dimensional vector in the cube $[0,1]^d$.
Why you divide it into cubes?
Presumably because you are calculating a histogram-based density estimate. When you do that in one dimension, you divide the interval into subintervals, and the analog of that in $d$-dim is to divide the cube into cubelets. Then counting the number of
Why is $N=(1/h)^d$ and the formula of the density estimator how did it
come?
The first part was explained in comments: Assuming that $h$ comes from dividing the side 1 into equal-length subintervals, then $N$ is just the number of cubelets. $\hat{\pi}_j$ is just the number of observations in cubelet $j$, divided into $n$. Then the formula for the histogram density estimator comes from:
- Assuming the density estimate should be constant in each cubelet.
- Letting that constant value be proportional to the number of observations falling in the cubelet (reasonable since all have the same volume.)
- Using that the integral of a density should be 1, so that
$$ \idotsint_{[0,1]^d} \hat{p}(x) \; dx = \sum\dotsi\sum \frac{\hat{\pi}_j}{h^d}\cdot h^d =1 $$
where the sum is over the cubelets. That should explain the formula.