--Not a teacher--
I don't know this but if I was to give a shot it would be like this:
One of the connotations of blue is being depressed, having melancholy etc. What I infer from the phrase is that there are two sides of being lonely; a positive and a negative one.
And the negative side is blue because it's the side that makes you depressed, sad...
Interested in Language