The nonprofit gives all its ownership rights to the for-profit in return for equity. The nonprofit is free to hold the equity and maintain control or sell the equity and use the proceeds for actual charitable purposes.
As long as the money doesn't go into someone's pocket, it's all good (except that Sam Altman is also getting equity but I assume they found a way to justify that.)
OpenAI will eventually be forced to convert from a public charity to a private foundation and will be forced to give away a certain percentage of their assets every year so this solves that problem also.