If you buy something for a song, it costs you next to nothing. When you need to get rid of an old car that's not worth much, you might sell it for a song.
For a song basically translates to "for a small amount or value," or "for a trifle." You might show off your thrift store boots, telling your friends, "They fit perfectly, and I got them for a song!" While these days songs aren't necessarily free — many people pay royalties for the honor of singing certain songs — it used to be the case that singing a song was free. Shakespeare used the phrase in "All's Well That Ends Well" in 1601.