For example...
For example, lying, killing, stealing, and wrongly accusing others are all actions which we consider to be a sin, and they indeed are. However, they are not considered to be a sin due to the bad nature of the action in itself. Rather, they are considered to be sins because Allah (SWT) forbid and prohibited them. So, killing in itself is not a sin, but Allah's forbiddance is what makes it a sin if committed.
This is a very important concept that we need to understand and recognize to avoid confusion and so that we can later understand the meaning of Taharah and ‘Ismah, like Allah (SWT) willed. So, if a person does not lie, in adherence or accordance to good behavior and commendable traits, this would not be considered “obedience to Allah (SWT)”, and he would not be characterized as “obedient” to Allah's order in this case.
He is certainly not equal to one who does not lie because of his adherence to Allah's prohibition to lying. In general, Allah (SWT) orders us to be truthful and honest. However, in certain and specific situations, He permits us to lie, and may even order us to do so. For example, lying on the enemies of Allah (SWT) and the enemies of the Muslims at the time of war is permissible, in order to avoid revealing the secrets of the Muslim army to the enemy.
So, the action in its outward appearance is a lie and a sin, but it is permissible since Allah (SWT) allowed for that in such an exceptional situation. Furthermore, in its outward appearance, Taqiyya (dissimulation) may be interpreted as lying, but Allah (SWT) has ordered us to observe it in special cases in order to protect ourselves, our money, property, and our family.
Allah (SWT) and the Holy Prophet (SA) have excused ‘Ammar ibn Yasser (RA), when he was forced by the nonbelievers to curse the Prophet (SA). ‘Ammar thought that he was doomed by committing that act.