How do I get an object to ensure it is perfectly in line with the x, y and the z axes?
My guess is that you joined one of the legs as the final active selection. The final active selection becomes the new origin (and orientation) for the combined objects. The left middle leg looks like it's rotated 48 degrees on Y. Start again, select the body last. If you have accidentally moved it in the process, AltR, AltG will set it back in place.