The explanation for this is often framed in the principle of free will, and indeed that is a major part of the answer. The extension of this point is that we do not live in a consequence free world.
What exactly does that mean? At its most basic it means that if you step off a cliff the natural laws which God has seen fit to enforce in his created universe will cause you to experience a world of hurt as your body makes contact with the ground below.
So in reality the Commandments and teachings which God has given us are warnings about how to avoid bad consequences. Many people point to the Ten Commandments and describe how they are the rules by which a society must live for a community to be able to live together. Certainly a community can not survive if the people in it steal from one another or commit adultery or bear false witness against each other.
In the new age the Church has illuminated the meanings of the original Ten Commandments to tell us about many other things which just seem to have bad consequences when we do them. Most of these consequences are present in this world, so that it really isn't necessary to talk about the dire consequences that will occur in the next.
Sometime the consequences don't seem to follow so directly from our point of view, but the Church has had centuries to think about and see the end results, and knows where individual actions will lead.
That is also why there is no such thing as a private sin. A sin hurts the whole community. There are consequences for the whole community.
This is not a popular stand today. People want a consequences free world. That ain't going to happen!
Live a promiscuous life and there will be consequences. There's heartbreak, low self esteem, using others as objects, which results in loneliness, possible pregnancy, guilt for "taking care" of that "problem", disease, and on and on.
Follow the cult of instant gratification and find a life bereft of meaning.
Cheat on your spouse and destroy your family, lose the respect of your children, your friends, possible even consign the woman you said you loved and your children to a life of poverty, since being from a single female parent household is the greatest indicator of poverty in the U.S.
The God who loves you wants you to avoid bad consequences. He wants it so bad that He has told us how to minimize the chances of making decisions which will cause us to experience a whole bunch of bad consequences. To do that avoid sin. Respect and follow the teachings of the Church. Teachings not created because the Church is anti-this or whata-phobic that, but because these actions, those lifestyles are bad for you. Thaey are bad because they have consequences, in this world as well as the next.