It was the time when both Lord Shiva and Kali had debate on who is the best dancer. To conclude and make a decision a competition was arranged. This was witnessed by all the God’s and Godess including sages.The dance performance started and each had their turn to demonstrate their talent and non are less competent. During this period, Shiva’s ear ring falls down and in order to avoid any hindrance to the performance he uses his right leg to pick the ear ring wars it his ear.
Kali being women cannot raise her legs that high in front of crowd and thus gets defeated. Hence she is in his temple in her dancing pose.