The first time we encounter Lily and James is in the fifth book, through Snape's pensieve. They are mentioned before that, but this is the first time we see them speaking to one another. We see James and a cocky, arrogant, quidditch playing jerk who is enamored with Lily Evans. Lily shows herself to have no interest in James, even though he is obviously incredibly taken with her. Since then, fanfiction writers and readers have become fascinated with this relationship which seems like unrequited love. Sirius and Remus tell Harry when he questioned them about his father that Lily and James eventually ended up dating in their seventh year, when James grew up a bit and realized that the way to sweep Lily off her feet was certainly not to act like a pompous git. There are many theories as to why/how Lily and James eventually fell in love. Nobody except J.K. Rowling knows.

Fanfiction writers and readers, (myself included) love to create their own stories as to how Lily Evans and James Potter fell in love. ;)