I always assumed that this saying originated in the printing business. Before the days of computers we used to create a word to print by putting a metal piece of type next to another with the character in relief on the top (and back to front) so when it was inked and paper pressed down on it, it was able to be read. When a line, paragraph or even a page of these metal characters were put together they were extremely unstable. Consequently were often knocked over and mixed up. This was called a pie. As an ex-compositor I can fully vouch that pies were extremely easy to create.
Far easier than creating a nice apple pie!