The usual advice for reselling a Switch is as follows:
- Transfer your data to a Switch which you will be keeping, if any. If you can't do this, you may lose any save data that wasn't backed up to the Nintendo cloud (requires a subscription, and does not cover all games). This will also delete the account from the Switch you are selling, which you probably wanted to do anyway
- Wipe the Switch entirely. As mentioned above, this will erase any save data that isn't backed up.
However, your situation is different, because you want to transfer the account, purchases, etc. to your friend, and don't care about backing up anything. That probably violates Nintendo's terms of service (which prohibit "any resale or commercial use of the Services or the Materials therein"), but you can change the email to point to your friend's address. This will require your friend to click a confirmation link. Either you or your friend can then change or reset the password as usual.
If Nintendo finds out that you have done this, it is possible they will revoke your digital purchases or take some other action against you or your friend. It's unlikely you or your friend would have any recourse if this happened. This is one reason to prefer physical purchases if you're not sure you're going to keep the system indefinitely; it is always legal to resell physical games, at least in the United States (and probably in most other countries).