I think that these two are causes rather then requirements. The fact that in our current culture it is awkward and socially wrong to "just organise that without a social excuse" and that we need "common activities and goals" to even consider socialization is why we are lonely.
Of course common activities and goals do help. But when they are the only thing, the relationship is destined to die the moment something changes.
But people who are not lonely tend to value relationships for themselves. They organize without excuse, send each other mails for no reason about ordinary life and call each other for no reason. What they do have is values that put priority on relationship and skills to keep them. There is also mutual reciprocity to some extend with helping each other and such.
A lot of these things are low-key stigmatized in some sub-cultures. The above is wasting time, just hanging around, just being social etc. See how spending a lot of time on phone was mocked - but it was reasonable way for people who dont have common activities and goals to keep relationships. The need for at least pretend common goal and important enough topic so that we dont feel like wasting time is more of symptom then the solution. Because it prevents us to keep relationship unless it is immediately useful.