Because I always treat the gradient of $f$ ($\nabla f$ ) as $\nabla_ifdx^i$.And the vector field should be $X=X^i\frac{\partial}{\partial x^i}$. So I am fuzzy with that why vector field can be the gradient of a function $f$.
The above question is on Riemanian manifold.
On any manifold, you can compute the differential $df$ of a real-valued function $f$, and $df$ is a covector field, also called a differential one-form. (And it's written with the index downstairs when working in coordinates or in abstract index notation.)
On a Riemannian manifold, you can use the metric to raise the index on $df$, and the result of this is (by definition) the gradient vector field $\nabla f$. (And it's written with the index upstairs.)