A wire seems to have charges flowing through it. When a compass is kept next to it, the needle deflects. The reason for the deflection is:
The flow of charges have an associated magnetic field
Flowing charges constitute an electric current. Now, we know that a current flowing through a conductor has a magnetic field associated with it. Hence, due to the influence of that magnetic field, the needle of the compass deflects.