I've written several times about loneliness, and I've come to a conclusion. We seek out relationships because we're built for them. God made humanity in God's image - which is always a Triune image, not simply a singular image. We were meant for relationship.
Our human relationships fall short of the relationships we were meant for - when Adam and Eve were "naked and unashamed," it was because there was no sin to come between them. But with sin coming between us, all our relationships are screwed up to one extent. Especially our relationship with God.
This is where I believe loneliness comes in. It's a reminder that we were made for more than this. It's a natural longing for heaven and for the relationship we will have one day.