Annie Proulx's sardonic The Shipping News certainly deals with this theme of loneliness, albeit in a rather unorthodox manner. The main character--certainly no hero--finds himself alone, left to raise his two daughter after his humiliating divorce. His aunt suggests that they return to their ancestral home in Nova Scotia where the protagonist, Quoyle, does not know how to swim, let alone navigate a boat. However, the lonesome and quirky second-rate newspaperman carves out a life and begins to realize love without misery.
Catcher in the Rye is the best example that jumps into mind. Holden feels alienated not just from other people but also from the whole of society. Things don't make sense to him and he struggles to understand and find someone he can relate to. His younger sister seems to be the only person he really feels comfortable with.
I teach one book in particular with the theme of loneliness, and that is Of Mice and Men by John Steinbeck. It deals with the loneliness of a man trying to find work during the Great Depression. Typically, especially in the West during that time, men wandered from place to place looking for work. It also deals different kinds of loneliness for different reasons: a woman who is lonely because she is unhappy in her marriage; a black man being lonely because his race is not accepted by society at the time. This would be a great book to study along with the theme you are looking for.
For a short, fast change of pace, look into Jonathan Livingston Seagull. As an allegory about the loneliness that comes from being "different" from the expectations of society, it's an interesting way of expressing the hope that can come out of that type of loneliness.
The book that comes to my mind is Charlotte Bronte's Jane Eyre. This novel deals with many different aspects of loneliness. The main character isn't always physically alone but she is almost always lonely. This novel certainly looks at the darker sides of human nature as well. The character Mr. Rochester is willing to go to enormous lengths to assuage his own loneliness.
Robinson Crusoe strikes me as an obvious choice, as the title character literally spends years on an island by himself. Another, more modern choice might be Catcher in the Rye- if there has ever been a more lonely, socially isolated character than Holden Cawfield, I don't know who it is. I would also echo the above mention of Ignatius J. Reilly from Confederacy of Dunces, though he is not completely alone, as we discover through his letters and certainly at the end of the book. One book that has not been mentioned is Scarlet Letter, where Hester Prynne is shunned by virtually everyone for her transgression.
I think that The Count of Monte Cristo by Alexandre Dumas would work. Much of the book involves the main character’s feelings of isolation. I also think that Great Expectations by Charles Dickens is a good example, because Pip feels lonely and isolated for much of the book. Treasure Island, Robinson Crusoe and The Call of the Wild all include details of loneliness. I also found this link.
There are sections in The Hobbit which are related to loneliness.
You also may want to take a look at The Chocolate Wars and A Separate Peace. Each of those books deals with the loneliness faced by young people working out their identities. On that note, you may also want to look at Catcher in the Rye, a novel with loneliness at its core.
Three novels that deal with loneliness in different ways: My Antonia, by Willa Cather, is autobiographical, dealing with the loneliness of a young girl whose family moves to the Nebraska plains at a pivotal time in her girlhood. Steppenwolf, by Hermann Hesse, depicts the loneliness and isolation of a middle-aged man in an urban setting. Confederacy of Dunces, published posthumously by John Kennedy Toole (by his mother) is a wrenching look at a man’s life-long loneliness. Finally, I would recommend Jack Kerouac’s On the Road, not because it consciously addresses personal loneliness but because it is the emblem of the Lost Generation, which was lonely and adrift in the otherwise overcrowded and over-busy culture of 1960’s America.