Very simply, the word "like" draws a direct comparison between two (or more) things and gives an approximation, and "such as" gives exact examples while invoking, but not including, the presence of more examples.
> > > "There were things at the market like apples, spices, and scarves"
> > > > In this sentence, "like" means that there were things similar to / including apples, spices, and scarves, but these might just be an approximation / guess that brings up the feeling of the things there, and might not really be what was there.
> > > "There were things at the market such as apples, spices, and scarves."
> > > > There were many things at the market, and apples, spices, and scarves, are exact examples of things that were really there. There were also other things there. "Such as" implies that the other things that were there were also similar to apples, spices, and scarves, and that these three items represent the feeling of and content of all the things at the market.
Despite these two phrases having distinct meanings, most people use them interchangeably and probably, use of one over the other comes down to personal preference. It is unlikely that most readers would debate over the use of "like" and "such as" unless the phrase could change the meaning in an important way!