Put simply, the particle is derived from the noun {}.
Bjarke Frellesvig provides a brief explanation in his book _A History of the Japanese Language_ (page 132).
> … The noun _pye_ "side, direction" was being grammaticalized as an _allative_ case particle _pye_ , but in the Old Japanese period had not yet acquired that status.
As for pronunciation, sound changes would have likely proceeded something like *pye > *pe > *ɸe > *we > e.