When a spacecraft is launched from Earth, its forward velocity combined with the gravitational pull of Earth cause it to travel in a curved path. As the spacecraft heads toward another planet, the gravitational pull of that planet factors in to the path the spacecraft takes. The more a spacecraft can “coast” with engines off, the lower the cost of the mission (rocket fuel is not cheap!).
Think of a quarterback throwing a football to a receiver. The initial impulse (throw) is all the football gets as far as power is concerned. The football follows a curved path into the hands of the receiver. Likewise, the quarterback throws the football to where the receiver is going to be, not necessarily to where the receiver is currently. So, the quarterback throws the football downfield as the receiver is running in that direction. In a perfectly thrown pass, the receiver’s running speed will bring him or her to the exact spot where the football arrives at hand-level.
Launching to Mars is similar to this. A spacecraft is given an initial impulse (launch) toward Mars and then shuts off its engines and coasts (obeying Newton’s First Law) until it gets close to its target. Depending on the mission, the spacecraft may slow down – to get into orbit or land – by using the Martian atmosphere or retro-rockets that fire opposite to the direction of travel (obeying Newton’s Third Law).
Though a spacecraft could follow a variety of curved paths from Earth to Mars, one path called the Hohmann transfer orbit uses the least energy and is thereby considered to be the most efficient.
The Hohmann transfer is an elliptical orbit with the sun at one focus of the ellipse that intersects the orbit of the target planet. Launch occurs when Earth is at Hohmann perihelion (the point of the Hohmann orbit that is closest to the sun). Arrival occurs when Mars is at Hohmann aphelion (the point of the Hohmann orbit that is farthest from the sun).
To make sure the spacecraft and Mars arrive at the same place at the same time, the spacecraft must launch within a particular window of time. This window is called the “launch window” and, depending on the target, can be a few minutes or as much as a few weeks in length.
A game on khanacademy.org lets you launch a satellite from Earth to Mars by setting launch date – Cruise to Mars
(Screenshot from the Game)
(Content reference – nasa.gov)