It's Magic!
When people with no technical background whatsoever ask what it means to write software/programs/do software engineering, I just tell them what it really is: magic. Magicians incant spells in an esoteric language to perform certain tasks, they wave their wands, and something magical happens. I incant certain spells in an esoteric language, I wiggle my mouse, and something magical happens (as far as they are concerned).
If they aren't convinced, I asked them to turn on their smart phone and tell me how anything on it really works. They usually say: "I dunno, it just does. I push buttons and stuff happens." Then I tell them: "Yes, exactly, but I know what is really going on, and it is basically the same as Harry Potter waving his wand and saying: 'Hocus pocus'" For all intents and purposes, to the layperson, I think this is a perfectly legitimate explanation.
Almost everyone knows who Harry Potter is, what he does, and what makes him special (at least that he is a magician and can do powerful things with magic). You can simply explain that sometimes magicians need to write their spells in a new language to make their magic even more powerful, which is not really that far from the truth. You can just tell them that you are studying the process of creating more powerful spellbooks to aid a generation of even more powerful wizards who can create even greater magic on their favorite consumer devices. Everyone appreciates that.
Epic Fail
If that fails, I fall back to the recipe example, because the non-uniformity of solutions at least teaches people that there is more than one way to skin a cat (or bake a cake), and this is part of what makes programming so tricky. It also helps put the person in the position of being the CPU and sometimes following instructions they might not understand (most people probably don't know the difference between baking soda and baking powder, and why a recipe would have one or the other).
Dead Ends
I don't like using math as an example, because to do math, you have to understand what the steps are for. You can't do very much math by following instructions blindly (well, you can, but that's not how humans learn it, usually). I don't like sorting as an example because it is too technical for the layperson to appreciate. If I am talking to someone who can appreciate the sorting example, then they probably already have some idea what programming is about, and likely have tried it themselves.