I think it's a great idea. You can go at your own pace and wander into "uncharted" territory.
Driving in Madrid is okay if you know where you're going! Are you planning on touring for the day and then returning with the car to sleep in Madrid? If you know how to get from point A to point B, it's not too bad. There are a lot of one-way streets which makes it difficult if you're not familiar with them. You can see where you want to go but getting there is a different story. Madrid traffic can be very bad, depends on the area and time of day. Gran Via is a good place to leave from but make sure you know how to get back. Stick to very large streets such as gran via, alcala, castellana, and you should be somewhat fine.
Make sure you get gas before you return to Madrid (unless you know exactly where a station is). Wandering the streets for a gas station will surely get you lost.
If your rental plans include a Saturday night and are for 5 days or less between Thursday and Wednesday, let me know. I have a good offer from Avis and can pass the number on. There are restrictions (such as the aforementioed) and you must have a credit card that covers insurance to make the offer worthwhile. It's not for everyone but if the days fit, let me know. I used to rent cars all the time with Avis and got to know the guy working in the garage where they clean the cars. Living in Madrid, I found it's actually cheaper to rent a car every weekend than to buy and maintain one.