Even when she's rich Sara is already a weird kid and pretty thoughtful for her age. After she loses her wealth... well, it turns out that she has a lot more time to sit around and ponder things than she did before. (When she's not running errands and sweeping out fireplaces, that is.) Poor Sara is separated from all the other students and not allowed to attend classes or play with them. The only people she talks to each day are her few friends (who have to sneak up at night to see her), Emily her doll, and a rat that she happens to befriend. It's quite a lonely life, being a pauper in Miss Minchin's care, and it's only made more lonesome by the fact that Sara is mourning the death of her deeply beloved father. But A Little Princess asks us: is being all by yourself always bad?
Sara is lonely even before she is exiled from her station at the boarding school, so she's actually able to survive using the same coping mechanisms she did before.
All of the little girls at the boarding school are lonely, because their parents have abandoned them. Sara is one example, but we also see this in characters like Lottie and Ermengarde.