Elon has said he will open source the algorithm since even before the purchase. He said it is for transparency.
Social media algorithms have done a lot of harm, covered and discussed endlessly on HN, and transparency would be a first step to reducing that harm.
I believe the move is in line with his original motivation.