For example, if you want to get the order data and print it, you can create a root script in Magento 2 by executing the below code.
<?php
use MagentoFrameworkAppBootstrap;
require 'app/bootstrap.php';
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('MagentoFrameworkAppState');
$state->setAreaCode('frontend');
echo 'My Script';

