WordPress homepage setup not working on first load

I would say that the parsing of the “hello world” post is due to the site home url being the default for new site initially. So after the theme functions.php file has run the first time on the first time the site is called your settings are updated by your code, then any future landing on the subsite home will be the home page as you want.

Have a go at tying your code to the new site creation hook.wpmu_new_blog

https://codex.wordpress.org/Plugin_API/Action_Reference/wpmu_new_blog