DEALING WITH THE LAW
It is the rare adventurer who doesnt run afoul of the law at some point in his/her career. You will know youre in trouble from the subtle Halt! Halt! Halt! Halt! Halt!... sound that the guards make as they tenderly bust your chops. When you suffer any damage under these circumstances, you will be offered the opportunity to surrender. It does not matter what the source of the damage is (falling, weapon strike, poison, disease, damage from sunlight -- any damage). As soon as you suffer damage, this message pops up and your reputation in the eyes of the law drops. If you want to protect your rep, you have a couple of choices:
If you choose to surrender, you will be hauled in front of a judge where you will have the opportunity to plead your case. A Guilty plea will result in a lesser sentence being imposed and you will be released outside of town. At the time of your release you will be a bit worse for the wear. It looks like all the guards in melee range at the time of your arrest get a free shot at you and game saves the damage until your release. Police Brutality seems to be a way of life for the town guards.
A Not Guilty plea will offer you the choice of lying to get out of the charge or debating the merits of the case. A Lie response will involve a check against your Streetwise skill. This check will be modified by any help the Thieves or Assassins Guilds may provide, which depends on the charge and your rank in the Guilds. A Debate response will involve a check against your Etiquette skill (again modified by the Thieves or Assassins, if applicable).
If you are found not guilty, you will be released outside of town (again, a bit worse for the wear). Interestingly enough, a finding of not guilty will not restore your reputation in the eyes of the law. Your legal reputation is determined by how many times you're arrested and for what charges. This is a reflection of the police philosophy of "So what if he got off on a technicality. He's still a punk." Like your reputation with the other factions in the game, your legal reputation will gradually be repaired as it moves one point closer to zero each month.
You can repair your reputation in the eyes of the law through a couple of merchant quests. One of the easiest is the merchant who needs to be escorted somewhere. He's on the run from either the law or from one of the guilds. When the guards show up (it's a random chance that it will be guards -- it could most easily be representatives from the Mages, Thieves or DB), you can turn him over to them. Your rep with the merchants will drop a little bit (easily fixed by completing another quest), but your rep with the law will increase. You can also complete the quest where you're falsely accused of stealing the gem from the merchant.
If neither of these is too appealing, you can fast-travel to burn time. Your rep with everyone moves 1 point closer to zero each game month. If you really want to burn a lot of time, sell your ship, horse and wagon and travel around the Bay on foot and camping out. It could take up to a year to move from the northeastern corner of High Rock to the southeast of Hammerfell and back. You'll probably want to stop at either end and do a couple of quests for each of your guilds, but it's a fairly painless method of repairing bad rep.
Back to the subject at hand, if the court finds you guilty of the crime charged, you will get to spend some days in prison (putting the screws to you if youre on a timed quest) and lose some gold pieces.
The crimes you can be charged with are:
Breaking and Entering/Attempted Breaking and Entering: This happens when you fail a second lockpicking attempt or try to force a locked exterior door. This includes accidentally hitting a door with your weapon while engaged in indoor combat (caution is advised for those mages who like to stand guard). If you encounter a locked door inside a building you can break and enter by making more than one attempt to open the door while in grab or steal mode. Basically, if it's a locked interior door, take your one free lockpicking attempt and then either bash or spell it open or ignore it.
Murder: Pretty much self-explanatory. Kill something youre not supposed to kill (like guards or townspeople).
Criminal Conspiracy: This one pops up when your rep with the law is particularly low (like hated or pond scum). Essentially the guards just up and decide to arrest you because you're in town and they figure you must be planning to break the law at some point during your stay.
Vagrancy: This happens when you try to rest in the area occupied by a town and youre not in a tavern or your house. This includes the area outside of the town, but still within the square occupied by the town.
Smuggling: A possibility when engaged in some of the shadier quests given by nobles and merchants.
Pickpocketing: Just that. Clicking on any person or critter while in steal mode will make a pickpocket attempt. If the attempt fails, the guards throw a pounding party with you as the guest of honor.
Theft/Larceny: Happens when you try to steal from a shop or go rummaging around in the boxes and such you find in houses and stores.
Crimes which exist in the game, but you cant be charged with (caution! it may be possible to be charged with these crimes, but I havent managed to key the right sequence of events):
High Treason: one of the crimes on the wish list for many players looking forward to TES3 (tentatively titled Morrowind). Essentially you endanger or kill the head honcho. Cant do it in the game, but dont think the idea hasnt crossed the mind of many a player.
Assault: Smacking someone (has to be a guard since townspeople only have 1 hit point), but not actually managing to kill them. Ive never managed to be charged with assault since if Im going to hit someone, Im going to hit them hard enough to kill them.
There are a few tricks to remember in dealing with the guards.
Remember, each time the surrender message pops up, your rep with the law drops according to the crime in memory at the time the message comes up. Its entirely possible to go from admired to pond scum in a matter of a couple of minutes. Try to preserve your rep in Daggerfall, Wayrest and Sentinel since youll be questing in those provinces and dont need the hassle of criminal conspiracy charges.
For more information you can read Legal Basics by Anchivius (one of the books you can find).