When lying is allowed ?

Only certain Shia sects practice Taqiyya.

But yeah, If such a practice was allowed. Why didn't the early Muslims just lie about their beliefs. They sure wouldn't have been persecuted then. Maybe they didn't do that because it's against our beliefs?