Well in the case of dry skin by removing the skin but maybe with bites, it's your body asking for attention and when the nerves have been stimulated by a scratch it perceives (albeit momentarily) that the requested attention has been delivered...or indeed that the insect (take mites or ticks) has been removed
When the cells in your skin are damaged in some way, the body produces chemicals to deal with it, such as histamine which widens the blood vessels. These chemicals irritate the nerve fibres in the skin which send signals to the central nervous system.
The signals are like pain signals, but they can be blocked if another signal occupies the same 'line' that the pain-like signal is using. So if you scratch, a less irritating sensation than itching, that message gets through.