By the time Jean Valjean rescues Cosette from the Thénardiers, she no longer remembers her mother. (She was about two when they last saw each other.) By the time she’s grown, she’s blocked out the trauma of those years so thoroughly that she’s forgotten that Valjean isn’t her real father.
This comes up when Valjean, drawing on his experience as a mayor, lays out a false paper trail giving her a legitimate family history (all dead) so she can legally marry. The money he had stashed away is presented as an inheritance from one of these dead relatives, setting her and Marius up for life.
It’s telling that he doesn’t fabricate this history in a way that makes him officially her father, but instead claims that he’s her uncle. (The nuns didn’t pay much attention to which Fauchelevent was Cosette’s father.)
In part it might be too easily disproven. Even if no one is looking for him anymore, he’s still a fugitive, and Thénardier at least is still out there. On the off chance he is found out, she’s insulated by being his ward and niece instead of his daughter. He even goes so far as to fake an injury so that he can’t sign her marriage certificate, so that there’s no risk of it being invalidated.
But he’s also already preparing to leave, and this makes it cleaner.
Also worth noting: the money he’s stashed away helps smooth over “a few peculiarities here and there” in the legalities. That’s not something Fantine would have had access to if she’d tried to pose as a widow back in Montrieul-sur-Mer and keep Cosette with her.