Dear student
Due to strong molecular attraction between the two surfaces at the point of contact frictional force comes into action. For the motion of the body, it has to overcome the attractive force. Thus the frictional force always acts opposite to the direction of the motion of the body at the contact point, so it opposes the motion of the body.
Regards