Is there any difference between these three pairs? If there is, is it the same difference?
I did it by myself.
I did it on my own.
He lives by himself.
He lives on his own.
We're by ourselves.
We're on our own.
In looking into questions of synonymy (or its absence) it is important to keep in mind that individual words and phrases themselves do not have atomic meaning: they have not only ranges of meanings, and different meanings in different contexts, but also different ranges of meanings in different contexts. So even in such distinct contexts as you provide you may discover instances where the two phrases are essentially synonymous, instances where only one or the other phrases is usable, and instances where both may be used but they have different meanings. There is not necessarily a 'core meaning' to any word/phrase, or 'core difference' between two words/phrases, which translates predictably from one context to the next.
Let's look at the phrases 1) by Xself and 2) on X own in three different contexts: a) with do, b) with live, and c) with be.
1a: I did it by myself.
2a: I did it on my own.
1b: He lives by himself.
2b: He lives on his own.
1c: We're by ourselves.
2c: We're on our own.
I agree with @FumbleFingers on the 'nobody is here except us' / 'nobody will help us' difference. Further more:
1: I did it by myself can convey a positive meaning (you're proud of yourself)
2: I did it on my own tends to convey a negative one (nobody was here to help me so I had to do it... by myself)
In your 4rd example:
He lives on his own
If I had to imagine a situation, I would say that he is a young adult and life sad circumstances (like the death of his parents) made him rent a house. He had no source of care.
While the 3rd example
He lives by himself
Makes me imagine he's an independent young adult that took the opportunity to live alone.