The question is answered in the Shrimad Bhagavata Purana. It was asked by Yuddhishtra and answered by Bhagwan Krishna Himself:
"Dear Yuddhishtra! On whomsoever I wish to bestow My grace, I gradually relieve him of his money. Then his relatives, whom he had once considered as his own, finding him penniless and hard-pressed with adversity and sorrow, desert him. Then he works hard again to acquire wealth. I render all his efforts futile. In this manner, when he fails again and again, he develops dispassion towards earning money, understands the misery of his situation and withdraws himself from the world. At that moment, he forms friendship with my bhaktas. It is at this time that I shower My grace on him. Because of My grace he is able to realise the Supreme Soul, Brahman. Since My bhakti is so difficult and testing, many people leave it aside to worship other deities.
"Bhagawan Shiva is Ashutosh, which means that his heart melts easily and He gives His bhaktas the greatest of riches. Sometimes these devotees, on getting such wealth, become arrogant and puffed with pride. They forget the Gods that blessed them and spurn those very deities."
Gods Brahma, Vishnu and Shiva are all capable of giving boons and curses. But out of the three, Shiva and Brahma get pleased or angry very easily and therefore bless or curse instantaneously. However, Bhagawan Vishnu is not like that, it takes longer to please Him. (Shrimad Bhagavata Purana 10.88.12).
We must here realise that the Shrimad Bhagavatam is a Vaishnav Purana and describes the glory of Bhagawan Vishnu. Similarly, the glory of Bhagawan Shiva is extolled in the Shiva Purana. There is nothing conflicting about this. The chaitanya in Shiva is Brahman, and so is the chaitanya in Vishnu. They have two names and two forms, but the Brahman in both is one and the same.
In this context the Bhagavata Purana narrates a story. There was a demon named Vrika. The wicked-one once met the great sage Narada on the way and asked him which God out of the trinity of Brahma, Vishnu and Shiva was the most easily and quickly propitiated.
Narada advised him, "Go and propitiate Bhagawan Shiva and you will quickly accomplish your purpose. He gets pleased at the slightest quality and angry at the smallest offence. Ravana and the demon named Bana had performed only the slightest worship but Bhagawan Shiva was so pleased with them that he bestowed on them unparalleled prosperity and sovereignty. As a consequence, they later harassed the great God Himself (Ravana uprooted mount Kailasha where Shiva lived and Bana made Shiva the protector of his city).
Being thus advised, the demon went to Kedarnath and began worshipping Bhagawan Shiva by chopping of his own flesh and offering it into the sacred fire. When even after performing this ritual for six days Shiva did not present Himself, the demon began to despair. On the seventh day, he bathed in the holy waters of Kedarnath and began to cut his head with an axe to offer into the fire.
Just like when some unhappy person tries to commit suicide in this world we save him out of compassion, so did the supremely compassionate Bhagawan Shiva came and held demon's hands, preventing him from committing the act. By the blessed touch of Shiva, he was healed of his wounds and his body was restored.
Shiva spoke to the demon "Dear Vrika! It is enough, stop it. I want to give you a boon, ask for anything you want. I am pleased when simply water is offered to Me by My devotees. Why then are you torturing yourself so cruelly?"
The extremely sinful demon then asked for a boon that could spell terror for all living beings. He asked for the following: "On whoever’s head I place my hand, may that person die."
Bhagawan Shiva was unhappy at first at the boon the demon had asked for. But smiling mysteriously He gave the boon, which was just like feeding nectar to a serpent.
On receiving the boon, the demon became desirous of obtaining Goddess Parvati and on the pretext of testing the efficacy of the boon, tried to place his hand on the head of Shiva Himself. Now Shiva was afraid of the very boon that He Himself had given. He began to run in the north direction with the demon hot in pursuit. In this way he covered the entire earth and at last reached Vaikuntha, the abode of Bhagawan Vishnu. Perceiving the predicament of Shiva, Vishnu transformed Himself into a small boy and went on to Vrika’s way. The boy bowed respectfully before the demon and asked, "Dear Sir! You seem tired. Are you coming from afar? Please rest a little. It is this body which is the root of all pleasures and which fulfils all our desires. Hence, it should not be put to too much trouble. Is something bothering you? Let me know, maybe I can be of help."
Relaxed by the reassuring words of Bhagwan Vishnu, the demon described all that had transpired.
After hearing out the demon, the boy replied, "Is that it? We do not believe in what Shiva says. Don’t you know that He is the king of ghosts and goblins? How can such an exalted person like yourself believe the trivial words of Shiva? If you still have faith in Him, you may easily test the truth of His words by placing your hand on your"own head right now. If you find His words to be untrue, then you can kill Him so that He does not utter a lie again."
Hearing the hypnotising voice of Bhagawan Vishnu, the wicked demon in his forgetfulness placed his hand on his own head. That very moment he fell down dead and there arose voices from the heavens congratulating Bhagawan Vishnu for His act.
Vishnu addressed Shiva thus: "O Great Lord! The demon was finally destroyed by his own sins. No one who commits sin against a great person can be safe and happy in this world. What to say when that offence is committed against You, the Father of the World."
This story occurs in detail in the Shrimad Bhagavata Purana, 10.88.
References & Further Reading:
- G. P. Bhatt & J. L. Shastri (tr). The Bhagavata Purana (5 Volumes): Delhi 2002
- Saraswati, Swami Akhandananda (tr). Bhagwatamrit: The Elixir of the Bhagawat: Mumbai 2005
- Saraswati, Swami Akhandananda Bhagavata Darshan (Collection of Discourses in Two Volumes): Mumbai 2003
- Saraswati, Swami Akhandananda (tr). Shrimad Bhagavata Purana (2 Volumes): Gorakhpur 2004