Here is the misunderstanding:
Now, if the magnetic force is greater than mg, the wire moves up. Now magnetic force is up and displacement is up too which means that work done by magnetic force should be positive.
The statement that a magnetic field does no work is of a static magnetic field. You are positing a changing magnetic field by the word "greater" and "moves". To become greater energy has been supplied and it is not the static condition. That changing magnetic fields do work is evident :
An electromagnetic crane is a type of crane with an electromagnetic lift. Electromagnetic cranes are commonly utilized in lifting and moving various scrap metals. It does not have the mechanical 'pincers' of a regular crane, instead, it has a large flat magnet which draws the metallic materials to it.