Is it legal to use images from social networks for research?
In order to copy or redistribute images that you don't own, you have to comply with the terms of the license under which the owners have released the images.

Some images are released under licenses (such as Creative Commons licenses) that allow copying and redistribution under various conditions (e.g. attribution, non-commercial use only, etc.  - depending on the specific license.) 

For example, the People In Photo Albums dataset was "collected from Flickr photos
with creative commons licenses", according to the paper. Similarly, Yahoo! Labs compiled a dataset of One Hundred Million Creative Commons Flickr Images. And Google released an Open Images Dataset dataset of images that are listed as having Creative Commons licenses.

If there is no license accompanying the image or no blanket license applying to all images on the site, you have to assume that it is All Rights Reserved - in this case, you would not be able to redistribute these images.