Walt was a bad person. That’s the whole point of the show. Remember, he was offered the complete cost of his treatment at the beginning but turned it down. Walt wanted to be Heisenberg.
In the judge everything he does is to save his son. He’s a good person who makes bad choices in a crappy situation.