Haruhi Suzumiya from the Melancholy of Haruhi Suzumiya and Lain Iwakura from Serial Experiments Lain seem to have nothing common other than both being gods. But when one inspects the arcs that the two go through, it is interesting to find several parallels, in which their conclusions are diametrically opposed to each other. Keep in mind that this analysis spoils Serial Experiments Lain and the first season of the Melancholy of Haruhi Suzumiya in their entirety.
Initially, both characters are portrayed with a detachment from everyone around them. Haruhi distances herself from others through eccentricities whereas Lain does so through shyness. Both involve a sense of pursuit of fantasy opposed to reality. For Haruhi, this is through her attempts to escape the mundane by pursuing the supernatural. For Lain, this is through actions such as observing smoke from her fingers rather than paying attention to what's happening in class.
Both characters have an individual(s) to grant them acknowledgement, Haruhi through Kyon and Lain through Arisu and her friends. Their central motivating drive follows after the beginning of these relationships, with Haruhi's ambition to form the SOS brigade and Lain's interest in the wired. While both gain temporary satisfaction by embarking on these endeavors, it doesn't last. Amidst the process, both characters reflect an aspect of human conflict that that be generalized to the majority of individuals. Haruhi's slump prompts her to explain her belief that love is a disease but that she cannot deny she has such impulses, demonstrating the pervasiveness of human desires regardless of one's rationalization. Meanwhile, Lain demonstrates a temporary sense of satisfaction that she gained from pursuing the wired; momentarily, she became more social towards her friends and more ambitious. However, such stimuli only provided a temporary benefit. Lain reverts to her old self afterwards.
Both Haruhi and Lain have a central existential question whose answer they seek. Haruhi strives to find significance and meaning in a world where individuals are inherently insignificant in the grand scheme of things, while Lain wishes to understand who she is, her place in the world and who cares about her. Haruhi seeks to assert that she matters, and Lain at points supposedly imagines that everyone around her tells her "I love you." Both reach a state of hopelessness when they are unable to solve their problems. Haruhi descends into a progressing state of melancholy until she initiates the creation of a new world. Lain amidst her desperation comes across Eiri. As Haruhi creates this world with her god-like powers, she's effectively embracing herself as god, while Lain comes into contact with a self-proclaimed god. Although both characters are uncertain about this new set of circumstances at first, both come to terms with it, believing that it solves all their problems. Haruhi embraces the Celestials and chooses to follow through with the creation of the new world, while Lain convinces herself that her purpose is merely to connect the real world and the wired.
Both are convinced that they have found the right solution to their existential problems, but human connection prevents them from fully embracing these wrong solutions to their questions. Kyon connects Haruhi back to humanity through the kiss, and Arisu does so for Lain through showing Lain how to feel the heart. Both characters were consumed by an opportunity that their statuses as abnormal entities enabled, but through such connections were able to overcome them.
How the two diametrically oppose each other lies in what follows. By returning from her escapism in the "dream" world, Haruhi effectively rejects herself as god, as what's of value is her connection towards Kyon and simply appreciating life and the mundane for what it is. This is the means by which she reaches a conclusion to her question of meaning. Lain by contrast sacrifices herself to erase the effects of her entire existence. Her uncertainly with her existence and purpose build up, but after being asked by her "father" whether she loves everyone, she reaches a conclusion. Lain as a god, now assumes the role as an omnipresent being who loves everyone. This aptly resolves her conflicts as she is everyone and her place is everywhere; what is notable isn't who loves her but rather that she loves everyone. The contrast between the two is almost poetic: Haruhi's conclusion involves becoming human rather than a god and realizing that she doesn't need to assert her worth because she is appreciated (by Kyon), whereas Lain's conclusion involves accepting herself as god and realizing that she appreciates all. In this regard, both characters interestingly reach a solution that effectively invalidates the question they ask. There is nothing Haruhi needs to pursue as her satisfaction exists in the place right in front of her, in regular interaction. There is no one particular place for Lain as her place is everywhere.
After these conclusions, it is note-worthy to look at the interactions that the two characters take. Haruhi demonstrates how she seeks meaning in the concert episode "Live Alive" when her resolution to her melancholic state is her passion to simply act, regardless of how pointless said action may be in the grand scheme of significance. Her interactions in the rain episode "Someday in the Rain" demonstrate the importance of appreciating mundanity and the little things in her life; nothing happens which would unsettle Haruhi usually, but by taking pride in being with Kyon, she can overcome this. Lain sacrificed herself for the benefit of everyone but still has an inclination to crave connection. As such, she meets adult Arisu one final time, while still resolved to not reveal who she is to accept her new role. Despite the diametrically opposed conclusions the two characters reach, they ultimately crave a sense of connection that they beautifully achieve with the one closest to them.
It is almost astounding that such parallels could exist in series completely unrelated to each other. Although it's almost certainly a coincidence, that such a parallel could occur is beautiful in itself. Haruhi Suzumia and Lain Iwakura fulfill a sort of duality in this sense, which personally is satisfying as they are some of my favorite anime characters.