If you fire them, you may have an even bigger risk in training new developers to take their place. So you will need to evaluate the situation carefully and come up with a plan. There are several possible courses of action and I've outlined a few here.
In particular, you will need to pay close attention to your performance system. Like any continuous improvement system, you need to identify the key things you want to change and then measure them. So whether its lines of code produced per day, number of bugs, or number of completed projects, have performance standards, measure them, and consider tying them to your compensation or reward system.
Another action to consider is using AI or Appreciative Inquiry. Invite the developers to an AI session where they are told that they are good and you need to achieve better. Ask for their inputs on what will make them more productive. Put together a plan from that and share it with them so they can see the progress you are making in achieving the goals.
At some point, regardless of the course of action(s) you choose, there are some other factors to consider. Just because they are not meeting your goals, does not mean the goals are realistic. This is an opportunity to identify high performing organizations in your area, network with them to find out what they attribute their success to, and then enact them.
Finally, if for some period of time you are not seeing the changes you think should be occurring, you may want to consider more drastic action. Perhaps there is a way to create a "lull" in project requirements for a while and turn over the staff. Or you may temporarily hire more resources and consider letting the non-performers go as new resources are coming up to speed. You will need to be careful however to manage the expectations of the new staff -- you won't want them picking up the bad habits of the existing team. This can be accomplished through physical separation or separate management chains.
So the question you pose does not have a simple answer. You need to make sure you can measure current productivity and the effect of any changes you make. You will need to do so in a positive and constructive way so as to not decrease productivity. Unfortunately delaying actions sometimes just embeds the bad practices into the culture, which makes it even harder to change. So you will need start with a solid picture of where you are, where you want to be, the changes that are going to take you there, and the strategies you will follow if you are not meeting plan.