According to Newton's law, an object which is at rest or in motion will continue its state of rest or motion unless and until an external force is applied to it. This property is known as inertia. Dust particles are at rest with respect to the carpet. When the carpet is beaten, the dust due to inertia tends to remain at rest while the carpet moves due to an external force applied. So, the dust comes out of the object.