"You don't have a leg to stand on." = You don't have any good reason to hold your opinion or you cannot possibly justify what you are doing. The image is an argument which can't stand up - merged with the person holding the opinion.
Basically, the speaker is saying in a colorful way that the person they are talking to cannot justify what that person believes or is trying to do. They have no leg to stand on.