When we put a charged object near an uncharged object, it produces opposite charges in the near end of the uncharged object by electric induction.
In the figure, we can see that glass rod is positively charged. If we bring it near an uncharged sphere, the sphere forms negative charge near the glass rod, and positive charged on the end away from glass rod.
Since there is positive charge in rod, and negative charge in sphere, they attract