As many have indicated doing preventive maintenance is a key. Don't wait until something goes wrong to,fix. Get up on the roof and look around every so often. Check caulking, for cracks, tears etc. Caulking needs replacing after time, don't wait until it leaks.
Keep steel areas painted. Keep things lubricated including any slide out seals and gears. Keep it clean and waxed. Cover your tires. When you buy one get a travel trailer or fiver that is made well and has positive feedback. Paying a little more up front for a good RV goes a long way.
You'll have issues but many times you can avoid bigger issues being pro-active. Well taken care of they will last decades.