it made me think about whether laws exist to protect us or to restrict us.
In my opinion, laws exist to restrict you, but you can also be protected by them. So murder being illegal means you are not allowed to do it, but it also means other people are not allowed to murder you too. But the reason for laws being restrictive is that people work for themselves, so the people in the government work for themselves. For a government to set up laws and enforce them, it must be in their interest to do so. You can also benefit from that as a normal person, but not always. Murder, rape, kidnappings, you may think these are the most severe crimes, but they are not, not to governments at least. Many of these crimes go unsolved, and the government wouldn't be too bothered. But if you rebel against a government, you will be punished in the harshest way possible, because you are directly threatening them.
but I agree with the idea of whether rape will be legal if they put laws for it,
It's not that rape will be legal. It's what is considered rape. Rape was never legal, because the word "rape" is an offence. It's like asking someone if he thinks he is evil. No one thinks he is evil. No one acts thinking they are wrong. If they think it's wrong, they won't do it. If they do it, they think it's right.
Rape is defined differently across countries and history. In the past, in some countries, if you marry the woman you forced to have sex with you, then it is not considered rape by law. If you bought a sex slave and had sex with her, it's not considered rape by law. In Medieval Europe, there were cases where the man argued if the woman got pregnant from the sex, it meant she consented to the sex. Even in USA and Europe, decades ago, many scenarios that are considered rape nowadays were not considered so back then. These days, if you have sex with a drunk girl, it can be rape because she was not in a state to give you consent. That would have been harder to argue in the past. If a girl followed a guy to his room, it can still be rape these days. It's not wrong. Imagine if you were the girl in these situations, indeed it doesn't mean you gave your consent for sex by doing these things. It's just that, it's hard for the judge to know whether you did by hearing about what happened. So, whether an sexual act is rape is hard to determine by nature. Some cases are obvious, but some are not.