Planning a wooden bed frame. I am considering why bed slats I've seen seem to always just rest loosely on top of the frame rather than join to both sides. I know wood expands and contracts with heat/humidity but since the ends of the bed are also expanding and contracting in the same direction, why would these need to be separate? Perhaps it's for easy replacement as they more likely break. Maybe it's due to the weight of the mattress and occupants? If I made then of similar strength to the header and footer rails, I would think these problems would go away.
I know wood expands and contracts with heat/humidity but since the ends of the bed are also expanding and contracting in the same direction, why would these need to be separate?
The slats aren't moving in the same direction as the ends of the bed just because they're both going side to side, they're at 90° to each other in the other axis (the ends being upright, the slats being flat). So this means the ends will tend to expand up and down, the slats along the long dimension of the bed.
Just in general, when boards are not joined together movement tends to be very easy to deal with because it's only each individual board's movement that you need to account for, which can be small enough in many cases you can ignore it1. It's when boards are joined together and these small movements become one larger movement that we have to pay attention.
As to why bed slats are frequently not attached I think it's simply because they can be, they don't have to be fixed in order to work. And by not fixing them you save time and effort in drilling holes, driving screws or whatever. But where it is important for one reason or another2 bed slats are fixed to bed frames.
1 As in the apron of a table for example.
2 Bed slats are stronger when fixed at the sides and quite a bit stronger when fixed very firmly, e.g. when glued down or mounted into a housing groove or dado.
Probably because they don't need to be attached. The weight of the mattress holds them in place. Screws that come loose or are not firmly set could tear the fabric of the mattress. Why add an extra step in assembling and disassembling of a bed if it doesn't solve a problem and potentially introduces one?
Bed slats often are fixed down at the ends. I've just checked the two cheap bed frames in my house and they are fixed down with a screw at each end. I made a rough bed this way a while ago and it was fine.
In cases I've seen where they are not fixed the slats have been pretty thin and with an upward curve so that when you lay your weight on them they flatten out. I'm guessing they do this either to give the bed extra spring or to save money on wood. As they flatten they effectively get longer so you cannot fix them rigidly at each end. You could fit the end of each slat into a mortise without glue but that would be a lot of work for little benefit. And as you say it would make replacement difficult if one broke.
I would recommend making the slats for your bed reasonably thick (3/4") and screwing them down. Or you could rest the ends loose on the bed frame and use spacer blocks to keep them correctly positioned.