The role of the scalar curvature in a nonlinear elliptic problem on Riemannian manifolds