This is a personal preference that depends entirely on your lifestyle and motivation.
Working out at home is incredibly convenient and budget-friendly. There's no travel time, no membership fees and you can work out whenever you want in the privacy of your own space. Many effective fitness routines, especially for beginners, require no equipment at all.
Working out at a gym provides access to a wider variety of equipment which can be great for diversifying your routine. The dedicated environment can also be a powerful motivator and you have access to professional trainers and group classes.
Neither option is inherently better than the other. The key is to choose the environment that makes you most likely to be consistent. If you know you'll be more motivated by the energy of a gym, that's your best bet. If you need the flexibility and ease of home workouts, that's the perfect place to start.