Caveat: It might be useful to distinguish between high volume low cost computers (like the mentioned CoCo) and low volume high cost machines (like Intel boards - or workstations). I assume the question to be rather about these high volume low cost machines.
Why were chips socketed in early computers?
There are several reasons:
Most important: Chips where not fitted by robots back then, but by hand. Thus any chip fitted wrong and soldered would make the whole board unusable (*1), while with sockets it's a simple swap to make it work.
Second, sockets can endure more abuse (in this case heat) than chips, thus having them inserted later increases acceptable tolerances during manufacturing and leads to a lower rate of failure (*2)
Next, fitting sockets instead of chips decouples production. Boards can be prepared, ready made and stocked until the time there are orders to fill.
As a result investment can be reduced by ordering the most expensive single part(s) -- the chips -- as late as possible (*3).
Similarly, this is helpful to keep board production running even when some chips are not available for some time (*4).
I would expect soldering all the other chips directly to the board, would both save money and improve reliability by eliminating one thing that can go wrong.
Yes. It does, as soon as there are automated placement machines and -- more importantly -- an order of sufficient size to keep capital cost in check.
I can understand doing this with RAM chips, because it's often feasible and desirable to upgrade these; I think the CoCo 1 did often receive RAM upgrades.
Not really, as that's something users may want, not necessarily the manufacturer.
As said before, this is focused on high volume/low cost machines. While all of the reasons are as well valid for the high performance/high cost boards, labor and stock cost are somewhat less important due to labor which is already rather intensive for small production runs, and stock cost aren't that big in the first place.
Further, the repair aspect wasn't any consideration for cheap, mass produced machines. Commodores share of a C64 was less than 150 USD during most of the time (in the late 1980s even less than 50 USD). There is not enough money to be made in repairing defective units beyond a bare function check. Even more so with the lower priced CoCo. So serviceability wasn't a major concern.
*1 - Yes, they could have had people assigned to desolder the chip(s), clean the through-holes and have new ones fitted and soldered. Except, that would have cost possibly more than the wholesale price of that (cheap) computer would have been.
*2 - Wave soldering is a rather secure process and around since at least 1947 (oldest usage I know). It does require to have the whole board plus all of the placed components preheated to 130-160 degree Celsius (depending on the process) for several minutes. In combination with (somewhat) early chips, this may cause failure within the chips. So using sockets instead during soldering was a great idea.
*3 - One reason why Commodore continued to use sockets for the more expensive chips even after using automated placement.
*4 - Commodore is well know to have run into these conditions several time - for example with some batches of C16.