The equilibrium of particles electrostatically confined by external forces and the competition between the electrostatic interaction and gravitational field