For the same reason as most other laws. For people to harmoniously co-exist, allowing socitieis to survive and flourish, basic codes of behavior are required.
Rape is a slightly more complex (and unpleasant) one, in that anti-rape laws were, intially, generally focused on the non-transgression of the property rights of the man to whom the raped woman "belonged" and the harm done to that man. Obviously, over time and as women's agency and rights became recognized, then rape laws (in some cultures, at least) became more focused on the harm (violence) against the victim themselves.
I think its fair to point out, in the context of this conversation, that biblical prohibitions of rape (which are largely confined to the Old Testament, Jesus didn't speak about it) are very much rooted in the notion of women as men's property (as was the wider view of the time) - hence the "punishment" for raping a virgin is a financial payment to her father and the forced marriage of rapist and victim. The Bible is largely unconcerned with the victims themselves.
I think it's very fair to say that most modern Christians' views of the moral wrongfulness of rape similarly come from the recognition of women's agency, and their right to be free from acts of violence, rather than from scripture.