I'll leave this here:
It's Bannable. It used to be encouraged but it has been so abused to hell that Sony actually had to limit the licenses from 5 devices to just 2.
There's also the possibility that your friend can take your account and run with it.
If you need more proof, check out the link below. This guy got his gamesharing account banned for a week, then when it was reinstated all his purchases were nullified (!), his download list cleared and now unable to use what he purchased. No refunds.
Circumvent the system, bad things happen.
Also, once you hit the Activation Limit, your content will be locked out and you will be unable to activate your own console. Then you have to convince your gamesharing partner to deactivate, IF he/she deactivates.
And not to mention you have to disclose your own password.
It's not "illeagal", however it is against the Terms of Service that you agreed to when you signed up for the Playstation Network. You can have your account banned for giving your password out to someone else. And giving your password to someone is not a good thing to do, even if this guy is your "friend". That doesn't mean he won't rip you off.
The PSN Terms of Service says:
"You must keep your password and other account details secret (other than your Online ID), and not share them with anyone else, to prevent unauthorised use of your Sony Entertainment Network account. If you share account details with someone who uses your account in breach of these Conditions or we believe that your account has been compromised, your account and/or access to Sony Entertainment Network may be suspended or terminated."
Gamesharing still works, but you can still get your account banned for gamesharing and you can still get your account stolen by gamesharing.