There are at least two different meanings for this word, depending on what you are talking about. There is one link for each meaning below.
First, legitimacy can refer to the status of a child that is born to parents who are married to one another. Such a child is said to be legitimate. This is as opposed to a child born to unmarried parents. Such a child is said to be illegitimate. However, this distinction is no longer relevant in legal terms (at least in the United States).
Therefore, it seems likely that you are referring to the second meaning of the word. There, the word refers to the right that a government or other authority figure has to rule.
Every authority figure has to get its right to rule from somewhere. In the United States, the government has the right to rule because it is set up by the Constitution and voted in by the people. By contrast, kings in ancient times claimed to rule by the will of God. In both cases, these are statements about legitimacy.
So it seems likely that you are asking about this second meaning. If so, legitimacy refers to the basis on which a government or authority figure can claim to have the right to rule.