What we need to do here is to clarify what is legal and what is illegal
It is my understanding that the following is true for the UK
You can make a copy of purchased recorded content, for your own use to a different form of media
This covers backup purposes and the creation of a CD copy of music etc for playback on the computer, or a digital music player, (there was an allowance always made to copy a CD to cassette for playing in the car).
Once you are the owner of the physical media, if you no longer wish to retain this you can dispose of it by sale or gift to any other person, so long as you destroy any copies made as per above, completely, prior to disposal. The new owner of the media would be entitled to make copies under the same restrictions as the original.
If this was not true then it would be illegal to buy a CD / DVD/ Book as a present for someone else. The content provider is only eligible for one payment for any particular physical media.
It is also perfectly legal to loan media to a third party either for payment or not without further payment to the content provider, That is the way that libraries and DVD hire companies operate
You enter the realm of illegality, once you copy the content, by any means, and give it to another person, whilst retaining the original, the sharing method is immaterial, it is equally illegal to physically copy a CD or Photocopy a book, as it is to use P2P networks to share.
Software is more confused as to what restrictions apply due to the clicking through of the EULA that is required to install - this has not been challenged in a court as yet so may or may not be legally binding.
Obviously each country will have it's own version of these statutes but the general position is normally the same, to my knowledge.
Although, for example, I believe that Apples EULA restriction on installing on non Apple hardware was rejected by a Swedish court some years ago