Gym vs working out at home

Which one is better and more beneficial? I feel like I’d be more obligated and motivated to go if I knew I was paying $30 a month for a membership. Thoughts?