If you’re using Easy Digital Downloads, this tutorial will show you how you can force a customer to create a user account at checkout, but only for orders over $0.00. If the customer’s order is $0.00 (free purchase) then creating a user account will be optional.
Make sure Disable Guest Checkout is not enabled, and Show Register / Login Form? is enabled. You can find these options under downloads -> settings -> misc. It should look like this:
Copy and paste the following function (mind the opening PHP tag) into your child theme’s functions.php or custom plugin.