If you need to separate the parts for some reason, you should have separate after parenting With Automatic Weights so that both the 2 edge loops (the one of the body and the one of the leg) are assigned to the same vertex groups with the same weights.
To fix the problem, first join the body to the legs (not sure why you've split the different parts but you can separate them again later), then in Edit mode select the body with L and move it upwards (on Z only) so that you can easily select the vertices that are on the edge loops on both parts, body and leg. Then select the edge loop of the body and remove from all groups:
Now, select one vertex of the body edge loops (1), shift select its corresponding body vertex (2), open the N panel and under Vertex Weights press the Copy button in order to assign the same vertex groups with the same weights to vertex 1:
Now move the body down until the vertices overlap, separate the body if you prefer to have separate pieces again (with L and P), and move the bones to test, it sould work.
Another way: Once you've joined the parts, select the body edge loop, activate the Snap to Vertex and Auto Merge options, move the body edge loop until it snaps to the leg edge loop, deactivate the Snap to Vertex and Auto Merge options, press V to rip, now the body edge loop has the same weights as the leg edge loop.