Dogs will roll on their backs for different reasons and they will commonly roll onto their back with all four legs in the air and they wiggle or sway.
There are several reasons why your dog is exhibiting this behavior including: Attention getting. Scratching an itch.