Biography
I Just Want To Have Friends, like The Four Loves, is a form of Wish-Fulfillment answering to the desire that some members of the audience have to form many close friendships. A probable reason this is so common in fictional media is the fact that a high amount of people consider themselves to have very few or no friends at all.note As this is not limited to real life, however, many fictional shy people and those with few or no friends look for the same fulfillment as the reader, leading to two variants of this trope:
Type A
While "doing something really cool" is the focus of most fantasies, they also tend to focus on the friendships the characters have. These fantasies often provide "idealized" friends that the audience presumably doesn’t have. While in Real Life a true friendship needs time and investment, in this kind of fantasy setting often the protagonist will obtain tailor-made deep bonds and friendships with little to no time or effort at all.
This also happens in Real Life online, where e-relationships eliminate most of the usual hardships of making friends and they help shy people to open themselves and show how they really are without worrying about their self-image.
Type B
Sometimes fictional characters do not so easily get friends handed to them with the plot. They are lonely from the start and desperately looking to make and keep friends. The reasons for their loneliness may vary but, in the end, a character who really wants friends may either try to go about it in the wrong way, make friends with the wrong people, or secretly angst about it behind a different facade. If they end up successful more often than not these fictional characters will turn out to have been sociable all along, especially for Shrinking Violets, nerds, Cool Losers, etc.
A common episode plot for situation comedies, especially domestic comedies: A teenage character seems to have no friends at the moment, has a "woe-is-me" fit, and wants to make friends now. After a series of pratfalls, the the Aesop usually winds up being that friendships are valuable but need to be chosen carefully and that they don't happen overnight.
In Real Life, this trope is defined psychologically as the "need to belong."
Note that, in the book The Four Loves, Lewis argues that phileo, Friendship, does not work that way — your friend is someone you have something (activity and/or views) in common with. If you do nothing and have no opinions, you can't have friends in the sense defined by him.
Related to Wish-Fulfillment and Friendless Background as these tropes are often, respectively, the meta and In-Universe justifications of this trope. Also related to I Just Want to Be Loved (a craving for love in general), The Four Loves (a general theory of love that includes friendship as one of its types), First Friend, and Imaginary Friend.
Compare with I Just Want to Be Beautiful, I Just Want to Be Normal, and I Just Want to Be Special, as these tropes are also something the character desires.
See also You Are Not Alone, False Friend, and Et Tu, Brute?.