I really didn't understand the ending of the movie "The House on Pine Street". I don't even know whether there really were supernatural events happening or it was all on her mind. Can someone explain?
This Director/Writer interview would seem to answer your questions
Was it all in her mind?
No. It's a haunted house. It's not in her mind, genuinely supernatural things are happening.
Why is the ghost there?
The Directors intentionally left the ending (and indeed the whole reasoning behind the ghost being stuck in the house) intentionally vague as a way of fighting back against what they see as an annoying tendency in modern ghost-horror films to overexplain why there are ghosts and how to get rid of them.
Though it was left intentionally vague, the ending seemed to indicate that, rather than an entity, the events were the main character's "energies" interacting with the "energies" of the house (the story works off the popular misconception that energy is some kind of nebulous cloud-like thing that can just float around).
The main character deals with an unwanted pregnancy, an unwanted move, a controlling mother, and a husband who seems to make decisions without considering her. As the story progresses, her mother becomes even more controlling, her mother and husband begin making decisions for her without consulting her or caring if she agrees, and everyone in her life seems completely apathetic to what she is experiencing, resulting in the strange instances in the house increasing and becoming more terrifying. In the end, while she speaks to the equally apathetic friend of her mother's, the house's energy manifests again and kills her husband. With her husband dead and the baby born, she is finally able to return to the place she never wanted to leave in the first place.
The explanation (by the mother's friend) was that her hatred of the place caused the energy to do what it did, but it seemed that the pressure to suppress her emotions and "make due" caused or strengthened the occurrences.
That's just my take on it, and the writers clearly meant for there to be no concrete answers.