More generally, boobytrapping stuff has lots of potential harm to lots of potential people. (gas company employees, police, etc). The fact that it's also harmful to thiefs is tangential.
Intending to you kill someone for robbing you is illegal as well if you are not in danger
Actually, that depends entirely on which state you live in. Some states under Castle Doctrine allow deadly force to prevent the commission of any felony in your home, including robbery.
That, so far as I know, does not apply to booby traps.
You're correct--the Castle Doctrine only pertains to places when you physically occupy them (home, or car/work in some states), so setting up something to injure or kill someone on another one of those premises does not fall within those guidelines.
I thought all that was necessary was to place warning signs. i.e. if you leave a big sign that says "warning this house is booby trapped and unsafe" that's sufficient to protect you against a burglar who sues you for the leg that your spring-loaded machete hacked off.
My middle school got bitten by this. The roof collapsed on a burglar and he successfully sued the school. At the time he was not doing anything illegal (as he was outside a public school). The roof was unsafe and we have laws against that to protect HVAC technicians and the like.
That's the thing. As a public school, at least in our area, you're allowed to be on the grounds when the school isn't open. You just can't go inside.
I once was ticketed for being at a park after sunset in our town. The cop explained to my friends and I that if we had just been across the street at the elementary school then it wouldn't have been a problem.