You don't have to think too hard to figure out that Kevin's confession that he fathered Julian with a Canadian girl is something the characters should already know, given that the precise reason why Sonny is on trial is because he impersonated him. Since the Canadian girl's surname was "McGrath," it would have been more logical in the context of the plot for Sonny to have impersonated a McGrath relative instead.
Actually, everyone already knew what Sonny was on trial for. Kevin just realized that the claim that he is Julian's real father was accurate. When we first meet Julian, he says he's from Buffalo, NY, where Kevin claims to have never been to. But during the trial, Julian says that he was born in Toronto, Ontario (Canada), and then Kevin remembers the one night stand.
Was the court proceding a trial for Sonny or a custody proceding for Julian? It seemed like it was serving as both, which is problematic on multiple levels. The rules of evidence are different in each, the goals of each are different, and it's probably unlikely that the same court would have jurisdiction to do both, much less do both AT ONCE.
It was a trail for Sonny, on account of 'defrauding the state of new york'. Kevin wants to save Sonny from jail, and that's why he claims to Julian's father, because if he's Julian's father and the court is based on Julian's 'abduction' by Sonny then if he refuses to press charges (and all testimony states that Sonny was a good, if illegal, father) than the state has less reason to punish Sonny. That was Kevin's line of logic. Social Services pretty much just shrugs.
As stated at the beginning, it was to determine the proper custody of Julian. Sonny's contention is that his taking custody of Julian was in the child's best interest, and so he wishes to prove that through character witnesses.