You need someone to pitch your songs and do your admin. If this is ALL you need, you could probably get a co-pub deal in which you retain part of your publishing and sign another part (usually half) away. That is not a bad deal unless you can do all of that on your own. Most of us cannot.
You trade it for a cut. There have been instances I have known of where an artist or record label asked for a share of the publishing in exchange for a cut. Depending on how much they ask for, this can be a good or bad deal. And, it can be a slippery slope. Once you do this one time, words gets around and you will get the same requests over and over. In rare instances, it’s probably a really good idea to give a little to get a lot. Just make sure that you are getting at least as much as you are getting back.
You trade it for a great working relationship. If you can find a great publisher that will mentor you, then you are wise to trade some (or sometimes even all) of your publishing for a great situation in which you can learn and grow as a writer. There are also cases where an artist will sign writers. If you can sign with an artist that loves your work and will cut lots of your songs, then it’s probably a no-brainer.
In every case, you need to weigh your options and make an educated guess. You want to do your best to make sure the trade is either in your favour or an equal trade. But, don’t view signing away your publishing as an “evil” that must be endured. In the right situation, it can be the best thing you ever did!