Whether it be fantasy, mystery, romance, or any other type of fiction, as well as non-fiction in most cases, when the good guy does something bad, they should be punished. This is very important, as it displays the morals and the ethics (they are different) of the author, as well as the protagonist and supporting characters. It's also the natural order of things the way God designed it. When someone does something wrong they should, and will be punished. [The last sentence is talking about real life, not books] There are some authors that try to avoid punishing their characters for doing wrong, this is completely wrong, and in addition to not being a good book, it also is against the Bible. Don't ask which books do this, I know of at least seven, and if I told you their titles it could spark unneeded debate.
For example, take this completely random situation (I just made it up, it is not from any book, also, don't judge it, it's just an example, I didn't spend hours editing it lol):
Sleen took a hammer to the window. He heard a crack and then glass falling on the ground.
He crept down the isles of the dark store, completely alone. He checked his watch, 1:30 AM, he only had five minutes to get it and get out. He found what he was looking for while waving his flashlight around. He brought out a hammer and smashed a lock on a cabinet, grabbed a small portable computer and ran for the door.
Sleen noticed a police car was parked on the other side of the street, the officer standing at the door of the building opposite to the store. The officer ran over to the door, not wasting a moment.
Now, we know nothing about this guy[Sleen], but let's assume he's a good guy. He works hard everyday to provide for his family of three, but he just has to have this computer. From here we can take the story two different ways, only one is Biblical, has morals/ethics, and only one makes sense.
As the officer got closer Sleen started to feel himself panic, he wasn't a bad guy, he was just in a bad situation. However the police officer didn't seem to be coming to arrest him, he simply waved and approached very friendly. "Whatcha got there?" the office asked while shining his flashlight on Sleen and then shining it on the window of the store that had been broken.
"Oh, nothing..." Sleen said nervously.
"You got the new Shiny-Laptopo(fictional computer)? I hear that this is the top-of-the-line computer."
"Really? That's good." Sleen said, still panicking within.
"Okay, well you have a good night now." The officer said as he turned to go back to the other building.
As the officer got closer Sleen started to feel himself panic, he wasn't a criminal, he didn't kill people, he just wanted a computer. The officer crossed the street in a flurry and brought his gun out from his belt, "Freeze! Put your hands in the air and set down the computer down softly," Sleen obeyed. "You're under arrest," the officer quickly grabbed his hands and cuffed them, then shuffled him over to the police car.
I don't think I need to tell you, but the second one is right. Does it make sense that a police officer would just let the person go after breaking into a store and stealing a laptop? No, it's against the law and against the Bible. This is something we've got to remember when writing, we can't let our good guys deeds go unpunished. We just can't. Now, you may ask "Are you saying that we should let our bad guys go unpunished?", and I would say yes. And no. Yes, they will not be punished yet, though sometimes you can throw in a defeat in battle or whatever fits to your book. The reason I say no though is because eventually they'll get what's coming to them. Take for example the devil. He sinned, he was punished by not being an angel, or being able to reside in Heaven, but in addition he'll be punished in the end, he will suffer forever in his pit.