You should book your car rental at least 2 weeks in advance if you want to get the best price. Any closer than that to the hire date and you are likely to pay a higher premium due to availability and urgency.
Most companies will allow you to book in excess of 60 days from the booking date. So the more you can book in advance, the more opportunities there will be to get discounted car hire.
Keep in mind that you can always use car hire comparison sites to find and compare the best car hire deals in the lead up to when you need to book a car rental. Many of the deals and discounts are passed onto the are rental companies, who then pass on the discounts to their customers.