Zameer here from the Shopify Developer Experience team.
As the documentation suggests, the `location_id` parameter is the ID of the physical location where the order was processed. It's value is independent of whether or not there is a customer associated with the order.
What's most likely the case is that you are retrieving a combination of orders that were created through the storefront and the API. When creating orders through the API, no `location_id` is required, which will result in a null value being returned on lookup.