No in many cases when used colloquially, they are the same. But legal refers to breaking/contravening the law or rules.
and Legitimate refers to having a legal right or claim on something or a legal right justification for a persons/companies actions.
" you were caught breaking the law, you acted illegally when you drove a car without a licence"
" Just because you had a medical emergency does not give you the legitimate right to drive over the speed limit"
"A multi national corporation does not have a legitimate/legal right to flounder the laws of other countries, just because they are powerful and can pay for expensive lawyers. When the poor people of those countries cannot afford to fight them in the courts".
you can interchange on the third sentence.
legal - illegal contrary to or forbidden by law especially criminal law.
legitimate -illegitimate the same but with additional meaning of being able or not able to defend with logic or reason
you can have an illegitimate child (born out of wedlock) because sex with consenting adults over the legal age would not produce an illegal child it would produce a child born against the social morals of that country at that time.
it gets a little complicated by a dictionary definition, when there was illegal sex (sex before the age of legal consent. and a child was born ). However we would still say an illegitimate child or at least used to in less tolerant times.