Ethics of gathering data from social networks for research
In the United States, if you are funded by any government agency (NIH, NSF, etc.) and you do research involving human subjects, you are required by law to get approval from an IRB (institutional review board). Research involving messages on social networks can, in some cases, be considered human subject research under this law. Similar laws exist in many other countries. 

Furthermore, many conferences and journals require prospective authors to have clearance from an IRB or similar ethics board if they submit a manuscript involving human subjects research. For example, ACM SIGMOBILE policy:


  As part of the submission process, authors of papers that describe experiments on human subjects, or that analyze nonpublic data derived from human subjects (even anonymized data), will be asked to certify that their work was vetted by an ethics review (e.g., IRB approval). We expect authors to follow the rules of their host institutions around data collection and experiments with human subjects.


Note that IRB approval must be obtained before you start working with human subjects, not after the fact.

Legal requirements aside, when working with human subjects or their private information, you have an ethical responsibility to get clearance from an independent third party. There is an obvious conflict of interest associated with having the researcher decide whether the research is ethical. That is the function of the IRB.

For an example of what not to do, see the case of the OKCupid data release and some of the fallout from that.