Cooperation promotes biodiversity and stability in a model ecosystem