To swear to God means to make a sincere Oath to God regarding a situation or show great "Sincerity and/ or Conviction" to a conversation or beliefs.
For example if you shoplifted or stole something and then you swear to God you'll never do that Shoplifting or stealing again then you're telling God that you promise to never do that ever again.
Not everyone who swears to God means what they say but sometimes they do mean it.
Swearing to God is not bad if you're a Christian as it means you're telling God that you promise to be good and that you'll never do something bad again.
If you curse at God then that swearing to God would be considered bad.
However to Swear to God to not do something again is a good thing and not a bad thing.
Even though I'm an atheist myself I will sometimes catch myself saying I swear to God about something even though I just am promising myself to never do something again.
Or you could be swearing to God to commit to doing something you're supposed to or need to do.
For example you could swear to God that you're gonna lose weight and follow through with the weight loss.