1.) The part about not having friends is a big, big issue. Bigger than most people think. You definitely need to have some friends and a social life outside your relationship. Even if it's just once a week, watching a game at your buddy's house (or whatever you like to do). Making friends outside of school can be a difficult nut to crack, but it essentially takes a.) having outside interests and b.) opening up to people and making the first move. But...your post was more about the feeling of Loneliness, so:
2.) If you indeed have a mental health issue, that could be a large part of the "loneliness" problem. You should definitely figure that out first. Relationships absolutely suffer when one person is going through a mental health issue and has not properly dealt with it.
IF, on the other hand, you're generally a happy, stable-mood type of person, then here's what I think (and keep in mind, this is just my experience):
When that feeling of loneliness arises in an otherwise solid and functional relationship, it means you're unhappy and either sub-consciously or consciously considering leaving the relationship. When you are considering leaving a relationship, your mind starts to put a distance between you and your partner. That distance causes you to step outside the "moment" and see the other person objectively, or as a stranger. You start feeling sad and guilty. You start thinking about how the other person would feel if you left. You start thinking about the good times you had. All of that stuff starts to weigh on you and make you sad.
This does NOT mean your relationship is over or has to end immediately (or ever). It just means you need to think, really sit down and think, about whether or not you're happy with the person and then, when you come to a conclusion about what might be bothering you, see if there's a way you can address it with them. You should be able to at least talk about it.
Every minute of your relationship does not have to be joyous or amazing or thrilling; one moment of sadness here or there does not mean it's over (or that you have a mental problem). But, if you're experiencing this sadness repeatedly, something is wrong, either with your emotional/mental health or with the relationship. Taking action and opening up to people are the best ways I've known to deal with these types of issues in my own life.
Hope this helps at all.