We use one or the other depending on the context. There isn't one simple rule differentiating them. We use ser in specific situations and estar in other specific situations. We have many specific lessons on these essential verbs. Here are some of the A1 and A2 lessons:
I hope this helps. There are more lessons on ser and estar for more advance levels.