What is the origin of PEMDAS? While working on a compiler's grammar to follow this, It occurred to me that although it's something we are all taught to and simply follow, I don't know the origin or the reason we do it in the first place. I've done some research, but feel an unfamiliarity with the subject is limiting results / scope of my search terms.
Is there some naturally-occurring basis? For example, if I think of the fundamentals of addition, taking say a fruit and another fruit you can observe two fruits, even negative integers make sense in terms of debt but is there any naturally occurring instance we base these precedence rules off of? Is it just an arbitrary but helpful omission tool as the answers here essentially conclude?
I understand and accept that it is a convention, but what I'm curious about is the motivation behind that being the decided convention? I don't see a definitive answer: There's some contention that it just makes 'sense' but I'm not convinced that doesn't just simply seem the case because it's such a socially ingrained concept and taught really early on.
 A: Reposting my own answer here:

Imagine a world in which BEDMAS does not exist and where it is
necessary to denote exactly in which order the operations in an
expression are evaluated, using parentheses. A valid expression looks
something like this:
$$((a + b) \times (c \div (d - e)))$$
Look at this expression. It has four operations and four sets of
parentheses. Every set of parentheses belongs to exactly one operation
and vice versa.
$$\color{red}(\color{orange}(3 \color{orange}+ 5\color{orange})
> \color{red}\times \color{blue}(6 \color{blue}\div \color{#00bf00}(9
> \color{#00bf00}- 7\color{#00bf00})\color{blue})\color{red})$$
With these parentheses, we know exactly how to evaluate this
expression. The result of this expression is $24$.
Now consider a large expression. What if you don't want to write all
these parentheses all the time? What if you want large expressions to
be easier to read? Wouldn't you think of ways to reduce the amount of
parentheses and general symbols you need in such a way that the
resulting expression is still unambiguous? Well, mathematicians would.
And that's why there is BEDMAS.
First, let's consider expressions that use only $+$. Consider the
expression $((a + b) + ((c + d) + e))$. This expression has enough
parentheses for the order of operations to be uniquely determined. But
there's a nice property of $+$: For any numbers $a, b, c$, it always
is the case that $(a+b)+c = a+(b+c)$. This is called the law of
associativity. Now if we have a bunch of sums of sums, we can just
leave out the parentheses between them, because no matter how you put
them back in, you always get the same result. Our expression
simplifies to $a + b + c + d + e$. Great, we've already got rid of a
lot of parentheses.
Next, let's add $\times$ to the fray. The law of associativity also
holds for $\times$, so we can write $a \times b \times c \times d
> \times e$ instead of $((a \times b) \times ((c \times d) \times e))$.
Now let's look at what happens when you combine $+$ and $\times$. We
know that $a + (b \times c)$ and $(a + b) \times c$ are different
expressions, so we can't remove the parentheses in both cases. But
here's a new law: We can rewrite $(a + b) \times c$ as $(a \times c) +
> (b \times c)$. This is the law of distributivity. This means that we
can write any expression using $+$ and $\times$ as an expression where
you always do all multiplications first, only then all additions.
As a consequence, we can invent a new way to hide parentheses. In a
term where multiplication and addition are next to each other without
parentheses, we agree always do the multiplication first. This way is
great, because when we use this, we can actually write any term using
$+$ and $\times$ without any parentheses at all!
Example:
Using the law of distributivity, we can rewrite
$$(a \times (b + ((c + d) \times (e + f))))$$ to $$((a \times b) +
> (((a \times (c \times e)) + (a \times (c \times f))) + ((a \times (d
> \times e)) + (a \times (d \times f)))))$$
There's a lot of operators here, but if we agree to do multiplication
first and remember the law of associativity, we get
$$a \times b + a \times c \times e + a \times c \times f + a \times d
> \times e + a \times d \times f$$
which does not contain any parentheses at all! This would not always
be possible if we evaluated from left to right or addition before
multiplication.
Now let's add subtraction. First, let's remember that there is a unary
minus sign that goes left of an expression, for example $-a$ is
shorthand for $(0-a)$. Consider a term of additions and subtractions:
$$(a - (b - (c + (d - e))))$$
Using the laws $a + (b - c) = (a + b) - c$, $~a - (b + c) = (a - b) -
> c$ and $a - (b - c) = (a-b) + c$, we can actually reorder this
sequence of operations so that the parentheses move as far left as
possible, so addition and subtraction are executed from left to right:
$$((((a - b) + c) + d) - e)$$
So let's just agree that unparenthesized addition and subtraction are
executed left to right. We get
$$a - b + c + d - e$$
This has the advantage that with this notation, you can actually
rewrite subtracting as adding negations using the unary $-$:
$$a + (-b) + c + d + (-e)$$
This method therefore makes a term much more easy to read and
understand, and this allows us to reorder the summands in this sum
much easier.
If we want to mix multiplication and subtraction, we again specify
that multiplication is done first.
Now let's come to division. Consider a term mixing multiplication and
division. Just as we had for addition and subtraction, we can reorder
the parentheses so that the operations are executed from left to
right, using perfectly analogous laws $a \times (b \div c) = (a \times
> b) \div c$, $~a \div (b \times c) = (a \div b) \div c$ and $a \div (b
> \div c) = (a\div b) \times c$.
We now agree to drop the parentheses when the operations are in fact
executed from left to right. So
$$(a \div (b \times (c \div (d \div e))))$$
becomes
$$((((a \div b) \div c) \times d) \div e)$$
which we write as $$a \div b \div c \times d \div e$$
Again, we can interpret division as multiplication with the inverse:
$$a \times (1 \div b) \times (1 \div c) \times d \times (1 \div e)$$
So this description is much easier to work with, for example we can
reorder this very easily.
When division is mixed with addition or subtraction, we say that
division is always executed first by default.
Now note that terms using $\div$ cannot always be written without
parentheses, for example $a \div (b + c)$.
Because of this, mathematicians actually don't use the $\div$ symbol
anymore. Instead, they use the fraction notation:
$$a \div b = \frac{a}{b}$$. The nice thing is that we can draw the
horizontal line in the middle as long as we want, and that the line
clearly separates what's above the line from what's below the line. So
we can drop some more parentheses:
$$a \div (b + c) = \frac{a}{b+c}$$
Compare this to
$$(a \div b) + c = \frac{a}{b} + c$$
Clearly we can tell the difference.
Like this, we can actually write any term using $+$, $-$, $\times$,
$\div$ completely without parentheses!
Consider the term $((a + b) \times (c \div (d - e)))$ from the top of
my answer. It has four sets of parentheses, which we can now
technically all avoid by using proper notation and expanding using the
distributive law:
$$a \times \frac{c}{d - e} + b \times \frac{c}{d-e}$$
Note that this expression would still usually be written as
$$(a + b) \times \frac{c}{d - e}$$
since this is actually easier to read and understand. We haven't
forbidden parentheses after all, we've just made ways to avoid having
to write them.
Now be aware that since nobody out of school actually uses $\div$,
precedence of $\times$ and $\div$ is not actually known common
consensus. This means that we do need to use parentheses when a $\div$
comes before a $\times$, just so people don't get confused.
Now we can finally have a look at the term in the picture of your
question:
$$6 - 1 \times 0 + 2 \div 2$$
If we replace the parentheses using the rules we've established, we
get
$$((6 - (1 \times 0)) + (2 \div 2)) = 7$$
which should now be perfectly unambiguous.
The rules we've established, as you might have guessed by now, are
exactly BEDMAS (or rather BDMAS, since I didn't talk about
exponentiation).
Note that if you just punch the given term into a calculator, you
won't get the same result, because the calculator evaluates the
operations in the order they're punched in, not in BEDMAS order. So a
calculator sees
$$((((6 - 1) \times 0) + 2) \div 2) = 1$$
which is clearly a different result. So just remember that calculators
can't do BEDMAS and you're good to go.
Here's a different expression:
$$24 \div 4 \times 3$$
What is the result of this expression? By common agreement, we do the
division first, but again, technically we should have added
parentheses because the agreement is not common enough knowledge. Or
we could just use the fraction notation instead of $\div$, in this
case we would get two different expressions:
$$\frac{24}{4}\times 3 \neq \frac{24}{4 \times 3}$$
So here we can clearly see the intended order, and all is well again.

