Why pain caused by blunt objects vanish after some time and return at the event of touching?
BASIC REASON WHY THE PAIN DISAPPEARS FOR SOMETIME:

There are gating mechanisms involving pain both in the spinal cord and in the brain.

Although the pain gating pathways in the brain are multifold complex,the spinal pathway can be simplified.
The latter may be understood in a simplified manner in 2 ways:


When there is a nociceptive stimulus,the epicritic receptors are stimulated.Sensory fibres from them synapse with internuncial neurons which inturn transmits impulses via the ascending tract to the periaquiductal grey. This region is capable of inhibiting pain impulse transmission to the spinal cord or thalamus by modulating impulses via the descending tracts.
This type is called supraspinal control
Another spinal reflex-type gate control operates in which stimulus like rubbing over the pained area ,application of warmth or cold causes inhibition of pain.
This is due to the impulses by large type (myelinated)A-fibres which arises from the  rubbed areas synapse with the internuncial neurons which are already synapsed with the epicritic sensory neurons of the dorsal root.The ends of such type of fibres release neurotransmitters that inhibits transmission of pain impulses through the internuncial neurons .
This is termed as segmental suppression


WHY DOES THE PAIN RETURN AGAIN:

This is because the pain receptors are the slowest to adapt.It's exactly as you said because it keeps the body apprised of tissue damaging stimulus.
So when there is the return of the noxious stimulus we can understand the tremendous summation effect which takes precedence over the gate control.

This occurs by a greater output of neurotransmitters from the synapse of the pain sensory fibres which outdoes the inhibitory effect of the neurotransmitters favouring gate control of pain.