We consider a class of nonlocal shape optimization problems for sets of fixed mass where the energy functional is given by an attractive/repulsive interaction potential in power-law form. We find that the existence of minimizers of this shape optimization problem depends crucially on the value of the mass. Our results include existence theorems for large mass and nonexistence theorems for small mass in the class where the attractive part of the potential is quadratic. In particular, for the case where the repulsion is given by the Newtonian potential, we prove that there is a critical value for the mass, above which balls are the unique minimizers, and below which minimizers fail to exist. The proofs rely on a relaxation of the variational problem to bounded densities, and recent progress on nonlocal obstacle problems.