If you're not an expert, you may not know what makes a foundation unsafe or how leaky that roof will be in a downpour. How well have the previous owners cared for the house?
Before you purchase a home, it's important to have a trustworthy home inspector come out and take a look at the shape it's in. A home inspector can tell you how long that roof is going to last and estimate when you'll need to do other costly repairs, like replace the hot water heater or overhaul the HVAC.
Keep in mind that what seems like an affordable home can become less affordable if you have to make these large repairs within a few years of purchasing.