It's an informal way of saying "anyway" and is used to:
* Introduce a change of topic: "We were talking about the weather, but anyways, how was your day?"
* Dismiss a previous point: "I tried to call you, but anyways, it doesn't matter now."
* Emphasize a point: "I'm tired, anyways, I'm going to bed."
While it's commonly used in casual speech and writing, some consider it grammatically incorrect. In more formal contexts, "anyway" is preferred.