Religious point of view:
Because sex was created for marriage. It is a gift meant to join two people into one in an emotional and physical entanglement to bring them closer together as a couple and to produce “fruit” of that love, one of the “fruits” is in the form of having children, which can be said to be a living sign of the love between spouses. So, anything that takes away from how the act is done, or in the manner in which it is done, thereby perverts its purpose and commits sin. So, anything that detracts from its purpose is using it in a way that goes against what it was designed for, meaning that it is going against God’s will for how it is to be used. These purposes also lend to why rape, masturbation, homosexual sex, and contraception are immoral.
Secular point of view:
It just makes sense. If you restrict sex to those who are married, then you restrict the situation in which children are brought into the world (ie. into a complete household). Studies show, as single mothers and fathers could probably tell you themselves, that raising a child is more difficult on one’s own, and in being married, there is the commitment to stay together and help raise the children together and to provide for them in every way. This also reduces the number of “unwanted” child births thereby reducing abortion rates and contraceptive use. Also, with tax benefits and such, raising a child is easier in a marriage.
One could say that they could use contraception outside of a marriage, but contraceptive pills are dangerous and men would rather not wear a condom. Also regardless of how “safe” you are being, contraception can fail, especially condoms. Also, with sex outside of marriage or commitment, there is an increase in the number of STDs. If sex were only ever performed in marriage, there wouldn’t be the worry of STDs anywhere near to the extent that we have today.
One could also talk about abortion, but abortion is wrong, but that’s another argument.
Why? Because God says it’s wrong, and it just makes sense.