They use a software and feed in the historical data for a flight's departure, arrival and block time for each specific route on a specific day. The software analyses this data and suggests a schedule for that flight. Other than the software, airlines also keep in mind certain variables to schedule flights!