1.
Each Apple device is linked/associated with an Apple ID of the person who did the setup.
Activation Lock prevents anyone who is not the owner from using this iPhone.
To unlock the Phone, you need the Apple ID and password of the previous owner (your friend), that were used during set up.
So you have to contact your friend.
You friend has to read -> this Apple article: What to do before you sell, give away, or trade in your iPhone, iPad, or iPod touch
What to do before you sell, give away, or trade in your iPhone, iPad, or iPod touch - Apple Support
Then he has to remove the iPhone from his account, see this Apple article:
Check your Apple ID device list to see where you're signed in
Check your Apple ID device list to see where you're signed in - Apple Support
Then you can sign in with your Apple ID.
See also the following Apple articles:
Activation Lock for iPhone, iPad, and iPod touch
Activation Lock for iPhone, iPad, and iPod touch - Apple Support
How to remove Activation Lock
How to remove Activation Lock – Apple Support (UK)
2.
If your friend forget the apple I'd and password, ask him to check his Apple ID via his email box, see this Apple article: If you forgot your Apple ID
If you forgot your Apple ID email address or phone number - Apple Support
OR see -> Having trouble signing in?
https://iforgot.apple.com/password/verify/appleid
See this Apple article: If you forgot your Apple ID password
If you forgot your Apple ID password - Apple Support
Then see this Apple article: What to do after you change your Apple ID or password
What to do after you change your Apple ID or password - Apple Support
3.
You can contact Apple support for help -> Get Support (apple.com)
You have to show proof of ownership of your product, provide all documentation showing your purchase of the device.
If you do not have additional proof of ownership, contact your friend. He may be able to provide the original purchase document.
Once Apple receive your proof of ownership, Apple will further review your request and provide an update.