Last tested: Apr 17, 2018
Probably because the query isn't tied to a Look or a dashboard, for example if the query was run from an explore page.
There are some cases where look/dashboard ids won't show up even if the query is from a look or dashboard. API queries from looks and dashboards will show up with Source = API 3.0 and will not have a look or dashboard id. Scheduled job queries will show up with two entries in the history table, one with Source = Scheduled Task and one with Source = Saved Look, but neither one will show the look id.