Why can't you modify the query in a template page?
According to WordPress best practices, the query should only be modified in functions.php.
functions.php
The query can only be run inside the Loop.
You can modify the query in a template page if you use pre_get_posts().
pre_get_posts()
Due to execution order, the query has already run by the time a template is loaded.