Given the traditional ACM copyright license, is it legal to publish the paper on ResearchGate? The ACM license states


  (iii) Post the Accepted Version of the Work on (1) the Author's home
  page, (2) the Owner's institutional repository, (3) any repository
  legally mandated by an agency funding the research on which the Work
  is based, and (4) any non-commercial repository or aggregation that
  does not duplicate ACM tables of contents, i.e., whose patterns of
  links do not substantially duplicate an ACM-copyrighted volume or
  issue. Non-commercial repositories are here understood as repositories
  owned by non-profit organizations that do not charge a fee for
  accessing deposited articles and that do not sell advertising or
  otherwise profit from serving articles.


Does this (somehow) include ResearchGate?
No. Researchgate is a for-profit organization that makes money from ads and job adverts. See for instance http://osc.universityofcalifornia.edu/2015/12/a-social-networking-site-is-not-an-open-access-repository/.

Also, if you share your paper there, the Researchgate TOS state that you, not them, have to cover all the legal costs in case they get sued (Article 3, comma 5).