For most of a year following his trial at Worms in April 1521, Martin Luther was in seclusion. During this time his associates at Wittenberg were implementing practical changes in the church there. One of Luther's closest associates, Philip Melanchthon, was reluctant to move forward on some changes in fear that they might tend toward sin.
If you are a preacher of grace, then preach a true and not a fictitious grace; if grace is true, you must bear a true and not a fictitious sin. God does not save people who are only fictitious sinners. Be a sinner and sin boldly, but believe and rejoice in Christ even more boldly, for he is victorious over sin, death, and the world. As long as we are in this world we have to sin. This life is not the dwelling place of righteousness but, as Peter says, we look for a new heaven and a new earth in which righteousness dwells (2 Peter 3:13). It is enough that by the riches of God’s glory we have come to know the Lamb that takes away the sin of the world (John 1:29). No sin will separate us from the Lamb, even though we commit fornication and murder a thousand times a day (cited in Hendrix, Martin Luther, 121-122).
The quote in question was in a letter of response to Melanchthon in which Luther encouraged him to decisive action. The quote is often taken out of context because Luther's pessimism regarding mankind's ability to rise above sinful behaviors is often underestimated. This pessimism, though, is what drove Luther to so elevate the grace of God extended towards us in Christ Jesus.
Luther was not encouraging Phillip to commit sin. Luther was saying, in effect, whether you act or not you are likely to commit sin so you may as well be bold in acting and bolder still in your reliance upon the grace of God.