I know there is an infinite, loving G‑d. It's just that I can't get my head around a few things in the Torah, like death penalties for gays, wizards, and people who curse their parents. Even if these people have erred, couldn't they just be asked to stop or be punished with exile? That's why it's hard to believe that a G‑d who can make a billion galaxies and stars would want us to kill over different beliefs.
Before answering your question, it's worthwhile to note just how difficult it actually is to impose the death penalty in Jewish law.
First of all, circumstantial evidence won't cut it. You need two impeccable witnesses who had observed the person transgressing an act punishable by death. Next, these two witnesses had to have warned the person of the capital punishment he could receive for doing the prohibited act, even if he already knew. Finally, the person must have committed the transgression immediately after the warning. Any hesitation and the death penalty is off. The same applies to other forms of punishment.
To meet all of these conditions and incur the death penalty seems more like committing suicide then simply transgressing.
Nevertheless, the questions remains: As long as you are not hurting anyone else, sinning is your own private business. Why should you receive any sort of punishment? To get to the bottom of this, let's fly to the moon.
On December 24, 1968, the crew of Apollo 8 made history as the first astronauts to go into orbit around both sides of the moon and beam back pictures of the lunar landscape. The next day, the Lubavitcher Rebbe, of blessed memory, discussed a lesson to be learned from the event.
Central Command trains the astronauts how to eat, sleep, dress, and behave in all areas of their life while on board. Deviations, they are told, can mean the waste of billions of dollars. Hearing that such large sums of government money are at stake, the astronauts take every detail of their instructions very seriously.
Moreover, astronaut compliance has nothing to do with how much, if at all, they understand the benefits of the instructions, or the damage caused by not complying. Only the experts on the ground, who spent years researching the issues, know all the specific details. Therefore, the astronauts follow orders without question, even if they don't know the entire reasoning behind everything, because they understand that there are dire consequences for themselves and their team members.
Neither does an astronaut say, "Look, I'm only one of three—which makes me the minority. So if I don't do everything correctly, it's not going to make such a difference." Rather, he knows that any one miscalculation on his part endangers not only himself, but the other two astronauts as well.
Like a flight manual, the Torah guides and instructs us for a safe mission through life. In it, G‑d warns us of the 365 don'ts (the negative commandments) that can derail us and jeopardize our life mission. We don't always know why certain actions are more damaging and dangerous than others, and therefore carry a more severe punishment. But Mission Control does. So we listen.
Moreover, our decisions impact not only ourselves, but our friends, family, community, and the entire world. Actually, the entire idea can be found in a Midrash, composed long before anyone dreamed of space travel:
Moses exclaimed, "One person sins, and You are angry at the entire community?"
Rabbi Shimon Bar Yochai taught a parable for this, of people sitting in a boat. One of them took a drill and began drilling underneath his seat.
"What are you doing?" demanded his friends.
"What concern is it of yours?" he responded. "Am I not drilling under my own seat?"
They said to him: "Yes, but the waters will come up and drown the entire boat."
The Mishnah states, "Why was the human being created alone? ... To teach you that every person must say: For me the world was created." This world, as well as all of the spiritual realms leading to it, was created for each and every person individually. As Maimonides teaches, "A person should always view himself and the entire world as if it is exactly balanced. If he does one mitzvah, he is meritorious, for he has weighed himself and the entire world to the side of merit, and he has caused for himself and for all, salvation and redemption."
Taking all this into account, let's look back at our situation: We're talking about a very stable, Torah-directed society—evidenced by the fact that there is a Bet Din that has the power to enforce Jewish law. We are talking about a community where people know the difference between right and wrong and only very rarely does someone step out of those boundaries. One person comes along and decides to do something totally outrageous, despite a warning from two witnesses and right in front of them, knowing exactly what he is doing and what will happen to him for doing it. Basically, drilling a hole in a watertight boat for every and any sin to enter.
Truthfully, I doubt that such cases occurred too often. Rabbi Akiva was of the opinion that a court that issues a death sentence once in 70 years is a murderous court. But the message is there: Don't imagine you're an island to yourself. Think twice before sinning. The entire world depends on you.