This superstition of knocking three times is an integral part of the Chinese culture and it is done out of respect for spirits that may be inside the room. The knocks are supposed to inform them of your arrival and to respectfully ask them to leave the room, while you occupy it for the duration of your stay.