A redated post.
Kant doesn't say that in order to be moral, you have to be religious. He is someone who thinks that other sorts of rational arguments about God don't decide the question either way (first cause arguments, arguments from evil, etc.) So, on his view, we are left with a choice of believing the world to contain a God, of believing in free will or not , and in believing that humans survive death.
On earth as we know it, virtue and happiness are not proportional. Virtuous people are sometimes miserable, nasty people are sometimes happy. (Think of all the murder cases which are never solved.)
Religious world-views presume the existence of a universe in which there is a future life in which happiness is apportioned according to virtue. Whether it is through a last judgment, or through a law of karma that puts you back on this earth either in good shape or in bad shape depending on your deeds, good prevails and evil fails, eventually.
Or you can accept a naturalistic world-view in which there is no mechanism for balancing the cosmic scales of justice. If wrong triumphs in the course of a lifetime, which is certainly seems to, then the story ends, people die, and feed the worms with no recompense for injustice. Hitler and Mother Teresa are in the same condition. They are dead.
The Kantian argument here strikes me as a distant cousin to Pascal's Wager. In Pascal's wager, you are looking at your own prospects, and "betting" on the world-view that pays off better. (Pascal, like Kant, was addressing the undecided. If your belief system is like that of Richard Dawkins, making yourself believe for either Pascalian or Kantian reasons is not an issue). The difference between the Kantian wager and the Pascalian is that you are "betting" on the world-view that will give you the most moral encouragement. You are not just betting on your own self-interest,, as you are in Pascal's Wager. Kant doesn't assume that you can't be moral without God. Pure practical reason tells you what is right and wrong, according to Kant. However, Kant maintains that you since can't settle the question of God any other way, you ought to choose based on the moral encouragement provided by each world-view.
Sometimes being moral is hard. In fact, all actions with moral worth are, according to Kant, done from duty as opposed to being done in accordance with duty, which means that when you do those actions, your inclinations or emotions are pulling you the other way. In other words, perfoming actions of moral worth, like breaking up, is hard to do. Is it more conducive to making the hard moral decisions we have to make to believe that there is no cosmic justice, or to believe that there is cosmic justice. Kant thinks the choice is a no-brainer, practical reason enjoins us to view the world as cosmically just, and therefore to accept the doctrines of God, freedom, and immortality.