Some dogs like to lean on people. Usually larger dogs will sit close and lean into you with much of their weight. A major reason some dogs lean is that they just want to get as close as possible to the person(s) they love. Dogs once lived in packs making them naturally social animals.
Some dogs constantly want to be petted which is a form of physical contact. If your dog sleeps with you, s/he will likely get as close to you as possible. One of my dogs, Murphy, likes to lie across my legs. It’s easy to pick up a small dog and hold it close, but what’s a large dog to do.
At one time the belief was that leaning dogs were showing dominance. But research has proven this false, something we dog lovers knew all the time.
When a dog leans on you, the response you show is a learning experience for your pup. You probably show your dog that this is accepted behavior making him/her happy at that point. The dog then knows that s/he will get the desired attention by leaning into you.
Leaning can also be a sign of fear or insecurity leading to separation anxiety. Or you may find it annoying. In any of these cases, if you need help with retraining, ask the advice of your veterinarian or an animal behaviorist.
On a personal note: My 85 lb. beloved Rottweiler Timo was terrified of thunderstorms. At those times she became a leaner, couldn’t get close enough to me. Contrary to what the “experts” advise, I would comfort her and that usually eased her fears. However there were times when that didn’t do the trick and as I didn’t have flower essences, the vet prescribed a small amount of xanax which helped.