Home Improvement Questions? Ask a Handyman for Answers ASAP
First make sure the hinges, especially the top ones, are tight. Otherwise, if the hinge side of the door is snug and the latch side has a gap (both at the horizontal opening at the top) you will need to either lower the hinge side or increase the height of the latch side (or vice-versa if the opposite is occurring). You can do this by removing the moldings and try smacking the snug side top down a bit at the jamb with a hammer (you can use a 1x4 or wider board (or shim) to distribute the hit more evenly and prevent damage). Be carefully not to break anything as it's possible that that side of the jamb is tight against the floor and it won't move. If that's the case you will need to raise the latch side of the door up towards the horizontal top jamb.
Use a pry bar and again make sure you use a shim or 1x4 board (if you can get it underneath the jamb at the floor level). Raise the jamb up until it is 1/8 inch (or tight) from the top jamb and try your door. If it works, good. Hold the pry bar and install new shims by nailing them to the 2x4's. This will hold your jamb up. Always take the door off the jamb before doing any of these remedies. Pop the door off at the hinge pins. You will be using a level that is at least 2 feet long. Level the top first then the sides. Shim and re-install the door. If the door is still off level then you will need to plane the door itself. I gave you the easiest way first by trying to tap the jamb back into place all the way to the most complex way of fixing it. All are homeowner friendly methods. If nothing else works you will need to buy a new door that is already attached to a jamb (you can buy them like that). One side of the jamb is attached to the door and the other slips in over it from the other room for a nice professional look. Good luck.
Hope I Helped :)