Trespassing may be illegal, but that breach of the law does not absolve a property owner from all responsibility. In certain situations, the owner could be held responsible for injuries that the person suffers, even if he or she was never supposed to be there in the first place.
The duty owed by the landowner is not to wantonly and intentionally cause an injury. This could mean warning the person about dangers that aren't clear and obvious.
For instance, signs could be put up on the property warning of the potential risks. If the person still goes on the land and is injured, the homeowner may then be able to claim he or she wasn't liable, having done everything possible to warn off the trespasser.
These laws are also the reason that people cannot erect traps on their own property that are designed to injure or kill a trespasser. This would be willfully causing an injury, and a landowner who does so may be held responsible, both criminally and financially.
In some senses, the liability of a homeowner or a landowner is what prompts people to put up signs saying "No Trespassing" or warning about a dangerous dog. These signs do help to prevent instances where people come onto the property without permission, but they also help make sure the landowner is legally covered if a trespasser is injured.
It's important to know your rights if you're hurt on someone else's property, no matter how it happened. You may find that the owner has some responsibility to provide compensation for medical bills and other such costs.
Source: FindLaw, "What You Need To Know about Premises Liability," accessed Nov. 17, 2017