How on earth did someone come up with phrases like apple-pie order and apple-pie bed? Certainly not through anything directly related to baked apple pies. It was likely through a distortion, accidental, jokingly, deliberate, from a French phrase in every case.
Another way of saying that something is in apple-pie order is to say that it is perfect from top to toe or from head to foot or in Old French, cap-a-pie which could have been altered by rough English tongues to apple-pie
An apple-pie bed is a bed that has been made with one of the sheets folded double, as a joke. So that anyone trying to lie down in it will be unable to get very far. The French for a folded sheet is nappe pile- which once again, sounds too much like apple-pie
Can you think of another reason?