There is no way you can encode every random N-bit value in N-1 or less bits just by shuffling bits.
for every random N-bit value, it is indeed impossible. but for every, exept two, random N-bit value turns out it is possible. main equation that govern that transormation :
2^N - 2 = summ of 2^N, N:=1 to N-1
1. You don't have any guarantee about the content of what you'll have to encode in the future.
2. There is no bit shuffling transformation that will give 1 to 1 correspondence between N bit values and N-x bit values. That's impossible.
You can do a scan of the data stream, see what values are most represented and encode them with less bits (Huffman, arithmetic coding...)
You can build a dictionary and substitute entries in the dictionary with references (LZ and other many variations)
You can do run-length encoding.
There are many combinations and optimizations of these techniques and others, have look at wikipedia for starters.
https://en.wikipedia.org/wiki/Lossless_compressionBut there is no way to only shuffle bits and get a bijection with smaller values.