Running out of stock of useful crystal balls it is hard to guess what the true cause is, here. But here are some things to check.
It partly depends on whether you use a "low normal" (without cable tension the cage is pulled to the sprockets with more teeth) or "high normal" (the spring pulls the cage to the sprockets with less teeth) rear derailer.
If it is the latter, you can try disconnecting the cable to see whether it shifts to end. If not, re-adjust the limit screw. If you then need to loosen the screw so far that the chain is frequently dropped off the end of the cassette, most likely your derailer hanger is bent. In this case the pulleys are not parallel to the cogs, throwing the chain off the cassette. If however it works properly disconnected, the might be friction in the cable housing that pulls the derailer inwards; read on.
In case you use a low normal derailer, don't disconnect the cable. You may want to check the same points as mentioned above, but before you have to make sure the cable tension is right. There might be just enough friction in the cable housing that some flex in the frame accounts for insufficient tension, especially if the shifter cable is routed around the bottom bracket. Try increasing it a bit. You may increase it until the other gears don't shift properly anymore, then back down slightly.
Note that if increasing the tension indeed fixes shifting to the highest gear, this will probably not solve all your shifting issues. Your trade off will likely be non smooth shifting to the lowest cog. Replace the cable housing (and the cable) to fix.