How can I create 301 redirects from "unclean" URLs?
The warning you're seeing is generated by the Redirect module when you try to redirect from a path (the part without the query string) which is already a valid Drupal path, which is true for your case (your redirect's source path is the site root, /): https://git.drupalcode.org/project/redirect/-/blob/8.x-1.x/src/Plugin/Field/FieldWidget/RedirectSourceWidget.php#L68. The query string is ignored in this validation step.

Without a query parameter, this would "cover up" the existing path and make it inaccessible, which is why the warning exists. But since your redirect does specify a query, this isn't a problem - the redirect only happens if the query matches ?page_id=123.

The warning should be safe to ignore; your initial approach was likely correct.