Bernard is used as a foil to compare his success to the dismal failure of Biff and Happy's lives, which of course is indirectly a comment on Willy Loman's failure as a father to bring up his children. Bernard is the son of Charley, who in the play is Willy's only friend and someone who tries to help him. Bernard was always mocked by Willy as a child, as he was studious and hardworking, but not good at sports in the same way that Biff and Happy were. Thus he was an object of scorn for Willy, who thought he wasn't "manly" enough. However, as an adult, he has worked hard to become a very good attorney, and is even going to argue a case in front of the Supreme Court. He stands as a living rebuke to Willy for the way in which Bernard has achieved the success to which his own boys have always worked towards but never managed to gain. Perhaps one of the most telling remarks that offers a subtle commentary on the differences between Charley and his son and Willy and his boys is that when Willy remarks that Bernard didn't mention about his case in front of the Supreme Court, Charley says:
He don't have to--he's gonna do it.
This of course contrasts quiet, purposeful action with the endless, impractical dreaming of Willy and his boys, that never gets further than mere speech.
Thus Bernard represents a character who has quietly but diligently worked at making a success of himself, and has succeeded. His purpose is as a foil to Biff and Happy, who, like their father, have not achieved their dreams.