I used to design spacecraft electronics and the question raised initially is a pretty board one. so it takes books to anser them. a few key guidelines nd simple, and not costly rules however can be observed to achieve good reliability:
-use conservative design rules (do worst case analysis, avoid failure propagation, e.g. one board failing and outputing ax voltage shall not damage subsequent board...)
-use proper derating. there are military standards out there that give guidance. this applies to parameters such as voltages, power, thermal...
-keep electronics cool. every 10-12K temp. increase reduces lifetime by about factor of 2.
-some part technologies are known for bad reliability and should be avoided: electrolytics, mechanical parts such as relays+switches, batteries. now sometimes this is not possible. but space qualified batteries are costly... crystals are not critical.
-try to avoid that the PCB is in the resonance frequency of anything around (motor...), bod heavy parts to boards, but without stressing leads
-avoid single point of failures (e.g., if you have a diode protecting a batteriy to discharge into some part of a circuitry, use two diodes in series). redundancy in general is regularily used in spacecraft.
-when doing the layout , and when soldering, avoid stress to components (bend components far from body...).
-in vacuum, rule of thumb, any component cunsuming more than 100mW should have conduction cooling and be cooled through the system, other parts are usually kept cool eoung through their leads. inner copper layers help distribute heat.
-moisure helps part aging, avoid it, conformally coat the board (but di not etrap agressive fluxes, these must be avoided anyways)
this is by far not exhaustive, obviously, and there is a reason why spacecrafts cost what they cost, but for non-industrial applications, a lot can already be done by proper design and observing simple rules as above.