There is no difference, except in level of formality.
And it doesn't really communicate a meaning, it is just a sort of departure ritual, like waving your hand.
"Bye" means two things: "Goodbye" and "we are being casual and relaxed so I don't need to say the whole word."
If you are not going to see someone for a long time, you would not be feeling casual and relaxed, you would be feeling serious, so you would probably say "goodbye," probably as part of something much longer. "Oh, goodbye, goodbye, Joan, have a wonderful time, please stay in touch, write to me, send pictures, take care, goodbye!"
Sometimes people, particularly women, will say "bye-bye" or "b'bye." In both cases, this is what you might say to a young child, so it is even more informal.
Similar, there is no difference between "hello" and "hi," except the level of formality.
for me i use goodbye to express that we may not see each other/talk again , but i use Bye when i'm sure i'll see the person i talk with or meet up with later/soon/tomorrow but i can say BYE is more common in any situation.