Is there any way you can make all the music you downloaded legal without having to delete it all?

Yes, buy it. BMG and other music industry groups have websites that you can go to that will allow you to pay for them. If it's over $1 per song, then just buy them from iTunes on the Apple site.