Ain't is slang, not good, grammatical English.
The song says "Ain't no sunshine when she's gone" meaning that when the girl is not there, he feels like the sun is not shining, meaning he is sad or depressed.
In proper English, you should not put two negatives together (Ain't and no), but it is done in informal or colloquial English.
The songwriter should have said "There isn't any sunshine when she is gone", but it just doesn't have the same rhythm, does it?