If you’re sitting there with a new computer and scratching your head trying to figure out how to get all your music from your iPod and iTunes library on your old computer, scratch no longer! This is how you do it.

Another alternative is the Lifehacker article Copy Music from Your iPhone or iPod to Your Computer for Free.
Update: And if you want to get your playlists on your new computer, you have to do this.
And you should also read this tip on Keeping iTunes Organized!