A mafia leader died in Montreal and his funeral was held in a Roman Catholic church. ( how can this happened when he ordered killings )>
Don, this is a great question, and one that I did not understand very well until only recently.
As a Lutheran, I was very familiar with the contrast between salvation by grace (purely a gift from God) versus salvation (in whole or in part) by good works, but I wondered how, if Roman Catholicism insisted man's good works play a role in salvation, so many Roman Catholics seemed so secure in their inattention to morality.
The answer is in a concept the Catechism of the Catholic Church calls the "Sacramental Economy." You might imagine this like a bank account where good works are deposits and sins are withdrawals, and the balance of the account is the sum total of the person's deeds. Now, this would seem quite hopeless since few of us could ever hope to do enough good to compensate for our sins, but there are other ways to compensate for sin and thus improve the balance of the account. The foremost of these is the Sacraments of the Church. In the understanding of many Catholics, these (and not the moral obedience to the commandments) are the first good works that come to mind to compensate for sins. Additionally, through prayer and devotion, one can access the excess merits of the saints which are stored in heaven. Finally, one can even use financial wealth to purchase an "indulgence," for the forgiveness of their own sins or those of someone else. Even if one dies with a negative balance, Purgatory is understood as a final opportunity for sins to be atoned for without losing salvation.
As regards to mafia ties of a deceased Roman Catholic, there are many possibilities. Of course there have been historical connections (during the Medieval era, for example) between organized crime and the Roman Catholic hierarchy, particularly the papacy. However, I would like to think that those are a relic of history and no longer relevant in present-day Roman Catholicism. Another potential explanation is that the parish priest was (whether intentionally or unintentionally) ignorant of the man's dealings.
More likely, however, it is related to the above understanding of good works. To the best of my understanding, the primary factor in burial from the church (and on a related note, salvation) is being in good standing with the Roman Catholic Church. If a mafia leader attends mass, participates in Reconciliation (a.k.a. Confession), and particularly receives Anointing before death, he is in good standing with the Church, regardless of his moral failings. While he would certainly not be a candidate for sainthood, he would not be considered a pagan or unbeliever either (even if there might be substantial purgatory time anticipated based on his moral performance).
While the above does not represent what I believe and teach as a Lutheran, I hope it helps to describe the method of Roman Catholic thought that might result in the scenario you describe above. Thanks for writing and don't hesitate to post a follow-up if you desire further explanation.