1.Do not protect yourself by a fence, but rather by your friends.
'rather' means that friends are preferable to a fence as a means of protection.
2. They lived here for 20 years.
This sentence is correct if they no longer live there or have died. 'they have lived' means that they still live here.