Why is the window only ~3 hours long, why not 2? why not 5? why not "until it launches"? I'm guessing range safety, they could only get a TFR that long?
First of all, a typical launch window for going towards Mars is about 2.5 hours maximum. As a goal is to send the payload towards Mars, that is one limit to the window.
Also, there are a number of other factors affecting a launch. These include:
- Availability of the range
- Personnel that are required. A lot of people are required on launch day from quite early, there are limits before people start to make mistakes.
- FAA waivers. In order to launch the rocket, they need to make sure there are no airplanes and boats in the launch area. There is a limit for how long they can keep people out of the flight zone.
Another minor factor in the timing of the launch is avoidance of other spacecraft and orbiting debris, as exemplified in a note posted on the Spaceflight Now mission update page for this test flight at 02/06/2018 13:47:
There is one collision avoidance cutout in the remainder of today's launch window at 3:56 p.m. EST (2056 GMT). The Falcon Heavy cannot launch at that time to ensure it does not get too close to another object already in space.
Another factor would be if you want to rendezvous with the ISS, something that SpaceX has been contracted to do. You want to end up in an orbit as close as safely possible to the ISS.
- ISS completes an orbit every 90 minutes, meaning it moves very fast across the ground and shrinks the launch window.
- ISS also has a relatively steep orbital inclination so that it sees more of the surface of the Earth. Because the Earth continues to rotate underneath ISS, it never crosses the same track over the ground more than once a day. Even then it will keep shifting slightly more and more westward each day.
Usually when organizations launch rockets, they'll reserve several days of launch windows around the same time each day in order to hit as close to a perfect rendezvous as possible. They're aiming for very particular spots in the sky, and the closer they can get to them, the less fuel they expend, the less money they spend.