So it will take you 1/4 of an hour (or 15 minutes) to drive 10 miles at 40 mph.
So in ideal conditions, you would leave at 8:15 - 0:15 = 8:00...but, you may encounter traffic or unplanned events that will slow you down.
Also, your speed will vary and it will not be 40 mph the entire way.
So I'd say play it safe and double that 15 minute time to 2*15 = 30 minutes
So you should leave at 8:15 - 0:30 = 7:45 am
Note: it doesn't hurt to be early. So even leaving before that will work as well.