Looking on various pages, the origin of ン seems to be very confused. Most lists either don't include ン, or list one theory. So far I've found the following options:
Wikipedia also mentions
For ン there is also the theory of it not being derived from kanji, but rather being a variation of the notation "レ" representing the sound [ɴ].
Is "we just don't know" all there is to say about the origin of ン?