That [free] agency is to bless us and to exalt us and to improve us. It's not to lead to our destruction. And God has forbidden some things, whether it's permissible or not, whether it's within our agency or not.
Elder Jeffrey R. Holland, Instagram post, March 17, 2022
We are free to do whatever we want to do in life. That's a God-given right (BTW, I am eternally grateful for those that protect that right). Remember, though, that we ARE NOT free to choose the consequences of whatever we do.
When Adam and Eve partook of the forbidden fruit (which was absolutely necessary for us to exist), He said the consequence of doing so was that thou wilt die. He wasn't saying something was going to murder them, or an accident would kill them, in an "or else" threatening manner, but that they would become mortal and, therefore, be able procreate and have children. In other words, we are here because of that choice.
But my point is, that Heavenly Father is guiding us, He is warning us of the consequences for certain actions. He WILL NOT take away our agency, or our neighbor's agency, even though those consequences might affect us too. If we are paying attention to Him, we will know how we should act and what decisions we should make in life.