Publishing in the music biz is the portion of a song that refers to the actual written work, and not the performance. The song writer's (the writer of the music and the writer of the lyrics, depending on how many writers are involved, the percentages break down differently) initially control the songs publishing. From that point the song can be licensed to labels, artists, or whoever is in the market for songs, and at that point the song can be recorded. Whoever owns the publishing is entitled to be paid a portion of all proceeds that result from the song. That includes all single sales, album sales, licensing, etc... Basically anytime that song generates any income from any possible source, the owners of the publishing are entitled to income.
When an artist records a song that the artist did not write, that artist doesn't own any publishing. This includes most pop stars. Their income is generally restricted to album royalties and touring.
In rap, most rappers write their own material, so if they didn't sign their publishing over, they are entitled to at least 50% of a songs publishing (the lyrics half). The producer, who is the writer of the music, is entitled to the other 50% of the song's publishing -- the music half.
Artists who eat of publishing heavily are song writers who write big songs for other artists. Someone like the Dream for example, who has written major hits for Beyonce and Rihanna, is an example of a guy who really banks off publishing (for example he wrote "Single Ladies" by Beyonce, so he gets paid for every sale of the song single, for every sale of the album that song appears on, any commercial use of the song in advertising and movies, anytime the song is played in stadiums or other public venues where music is played, anytime that song is streamed on internet services, anytime the song is played on radio, etc...).
When rappers produce and write their own material, then there is the somewhat rarer case where one individual controls 100% of the publishing for the whole song. Eminem is an artist who at the height of his popularity was writing and producing his own music. He made insane amounts of publishing money.
Producers, aka guys who write music, also get publishing. When producers sample, sometimes the original artist who performed the sample demands a portion or all of the producer's publishing for the right to use the sample. shyt can hurt.
A publishing company partners up with song writers, and in exchange for a piece of the publishing income, handles all aspects of the song, including getting the song placed on an artist's project, collecting royalties from the publishing, suing violators of the copyright (ie people who sample without permission), and anything else you can think of that comes up in the business of the selling of songs.
The best way to think about it is, publishing is the part of the music business that deal with WRITERS. Writers include writers of lyrics and writers of music.