The goal of the query optimizer is to formulate an execution plan for an SQL statement which (hopefully) processes the statement in the most efficient way possible.
In order to formulate such an execution plan, the query optimizer needs:
The text of the SQL statement (the «query»)
Schema information such as table definitions and available indexes.
Database statistics
The query optimizer produces an estimated execution plan (as opposed to an actual or a live query statistics execution plan).