Electric charges flows into the wire because when the two ends of the wire is connected to the battery then the battery generates an electric field in the wire. This electric field forces the free electrons (that the metal wire consists) to move toward the high potential (positive terminal) of the battery