Moral judgements of Bernie’s millions feel tired and lazy. I’m more interested in the fact that he had a choice between donating the money to the Treasury and possibly becoming the most powerful politician alive, and keeping the money - and he chose the money.
Yes, morality aside, it seems like the correct strategy to win. It increases chance of winning and also preserves optionality - if he gave away all the money, he would likely gain enough additional fame to write another bestseller.