*Something* is causing drag in the system. Drag which exceeds the ability of the spring inside the rear derailleur to default to its resting position. It could be one or more of any number of things. Starting at the top:
Fault in the shifter. The solution depends very much on the nature of the fault and even if it's fixable. Many modern shifters are non user serviceable.
Drag in the cable. Caused by a kink, or corrosion or the collapse of the cable outer or ferrule. Or as I discovered on a bike I worked on for a neighbour recently, a bb cable guide absolutely gunked up with dried mud and grass. The best solution is to replace both the inner and the outer casing including any ferrules. But you might get away with merely lubing the inner, after checking for kinks.
Damage to the derailleur itself. The top knuckle on many derailleurs is susceptible to being knocked or scratched. It deforms the relatively soft alu components where the body of the derailleur connects with a steel pin to the outer parallelogram. This can add enough friction to the joint to stop the derailleur returning. The derailleur will still climb happily into lower gears because it has the enormous power of your right thumb to push it, but has to rely on the wheezy little spring to return it. A little jewellers file will often be enough to remove the burr.
Assuming you possess a work stand. Disconnect the cable, turn the pedals and (obviously keeping your digits away from the moving parts) with your thumb physically push the derailleur across the cassette. Keep turning the pedals, let go of the derailleur. If it happily drops down all the way int top gear you've established that its not a derailleur problem.
Lube the cable. If that doesn't work replace the whole cable inner & outer.
If that doesn't sort it, it's probably new shifter time.