I was studying magnetic effects of electric current . I made an apparatus in which I set a straight wire above a magnetic compass and connected the wire to two cells of 9 volts. When I completed the circuit , the compass showed deflection . But after some time the deflection reduced and kept reducing until the compass needle pointed in its actual north south direction. I could not understand what the reason of this reduction in deflection could be . Please help me .
Your two cells have run down which is not surprising as you had connected a low resistance, the wire, to them.
This had resulted in a very large current flow and hence a rapid discharge of the cells.
To confirm this disconnect the cells and allow them to partially recover.
If the cells have not totally run down then during the recovery process the chemical reactions within the cells may allow the cells to deliver some current again.
Reconnect the cells to the wire and you might again see a (smaller) decaying deflection of the compass needle?
It is best not to totally discharge the cells before disconnecting and then reconnecting the wire to cells.
You might have seen a related effect when your torch goes out. You switch off the torch, wait for a minute or so, and then switch the torch on again. It comes on again.