Probably the biggest drawback in Audacity for loop based music is that it does not have snapping to beats. That’s a feature request, I can add your vote if you’d like.
The closest that we have is a plug-in that I wrote that creates creates labels for bars and beats. The plug-in is available here: https://forum.audacityteam.org/t/beat-per-minute-labels/20785/1
Have a read through that post as that describes what the plug-in does and how to use it.
Instructions for installing are here: http://wiki.audacityteam.org/wiki/Download_Nyquist_Plug-ins#Installing_Plug-ins
For a free drum machine, have a look at Hydrogen: http://www.hydrogen-music.org/hcms/
Some other plug-ins that you may find useful:
https://forum.audacityteam.org/t/change-speed-stretch-audio-to-a-specified-length/23332/1
https://forum.audacityteam.org/t/drum-machine-sound-files/24759/1
https://forum.audacityteam.org/t/nyquist-plug-in-the-kronx-echo-looper/14555/2
https://forum.audacityteam.org/t/metronome-looper/30680/1