Is the root index.php file part of the Core?

Yes, index.php is part of core and is liable to be overwritten.

In fact, if you look at the process to manually update WordPress, step 7 is:

Upload all new loose files from the root directory of the new version to your existing WordPress root directory

That may include index.php.

You can put custom PHP code in a custom plugin or theme. If using a pre-built theme, first create a child theme and then put your code in that child theme’s functions.php.