The flying carpet when placed in your hotkey bar and right clicked becomes an object in the game world, just like a minecart. Right clicking on the flying carpet will mount/dismount the carpet. While on the carpet you can move around at an increased rate (roughly between the Meteor Boots' walking and sprinting speeds). Pressing the jump button will move you up, pressing the sneak button will move you down.
Destroying the flying carpet object with any item or your fists will turn it back into an item you can place in your inventory, again similar to a minecart.