Dina demalchuta Dina, the law of the land is the law, is one of the most famous teachings of Jewish jurisprudence. While ostensibly a law relating to the paying of taxes, it reflects the deep loyalty Jews are to have to their countries of residence. This idea was initially formulated by the prophet Yirmiyahu (see chapter 29), when the Jewish people were about to go into exile for the first time following the Babylonian conquest of Israel.
It was Shmuel, a first generation Babylonian Amora, who formulated the law in its current form (Nedarim 28a). He was a student of Rabbi Yehuda HaNassi who, realizing that Jewish life in Israel was in irreversible decline, edited the Mishnah. Two of his primary students, Rav and Shmuel, laid the foundation of 800 years of Jewish scholarship in Bavel, and it was Shmuel who taught this fundamental principle of Jewish law.
Most interestingly, this law is not mentioned in the Mishnah but emerges from the Gemara's questioning of the Mishnah regarding the payment (or non-payment) of taxes. "One may take a vow to murderers, robbers, and tax collectors that it is terumah even though it is not terumah, that it is from the royal palace even though it is not from the royal palace" (Nedarim 27b).
Human beings are full of all kinds of unbelievable inconsistencies and contradictions. Our Mishnah advises how we may deal with those who would murder but would never eat "non-kosher" food; in this instance terumah, which was only allowed to be eaten by a kohen. A zar, non-kohen, who eats terumah is punished with "death at the hands of heaven" (a much more serious punishment than that received for eating non-kosher meat), and even Jewish murderers would refrain from eating such. Whether this was out of a warped degree of respect for the "clergy" or a reflection of a warped system of priorities in general matters little. Based on this premise, one being held up at "gunpoint" for his food was allowed to take a vow that the food before him was terumah, thereby thwarting the thief. (Presumably, the thief is unaware of this Mishnah in Nedarim, but is aware of the severity of both eating terumah and lying under oath). Even if there is no fear of being killed by the robber, one may take such a (false) vow to safeguard his food.
Alternatively, one could take an oath that the food belonged to the royal family; while one may steal and even kill commoners, starting up with the royal family was likely a career and life-ending move. To these rulings, the Gemara is silent, finding them non-surprising.
What the Gemara does question is why can one lie to a tax-collector and claim one's assets are not really his own. After all, Dina Demalchuta Dina obligates one to pay taxes. To this, the Gemara explains that we are dealing either with someone collecting much more than he should and pocketing the difference, or with a non-licensed tax collector who has no right to collect the monies in the first place. Jews must pay their taxes, but only their "fair share".
In Talmudic times, "fair share" meant it was authorized by the monarch. It might be extraordinarily high and not truly fair but, if it is authorized by the government, it must be paid.
It hardly needs reminding that Dina Demalchuta Dina was formulated in a non-democratic society, where tax monies did not go to serve the people but to enrich the king. Nonetheless, we were obligated to pay despite receiving little or no benefit from our tax dollar.
As Rav Herschel Schachter often notes (see for example here), the obligation to pay taxes today goes well beyond Dina Demalchuta Dina. Citizens of democratic countries join in partnership, where each partner (citizen) must contribute to ensure the running of the partnership,i.e. the country. As in all partnerships, the partners vote on how much each must contribute and the best use of funds with the decision of the majority binding on the minority. Thus, one who cheats on his taxes today is not stealing from the malchuta, the king, but is stealing from his neighbour. And in a country like Canada, one has 30 million neighbours. That is a lot until unless you happen to live in the United States.
Rav Moshe Feinstein famously described the United States of America as a malchut shel chesed, a kingdom of kindness. How fortunate we are today that we can pay taxes to democratic countries that grant Jews equal rights! How our ancestors would have yearned for such. And how especially fortunate are those who pay taxes to the State of Israel, greatly contributing to the success and security of a Jewish state.
 This, in turn, should not surprise us when we witness terrorist groups committing the most horrendous of acts, yet at the same time offering social services to others. Lehavdil, the Talmudic discussion surrounding Torah education for girls is based on the teaching that a sotah, a suspected adulterer (who indeed committed adultery secretly), may have her Divine punishment suspended because of her meritorious deeds (Sotah 20a). Human beings are extremely complex--and I am not now referring to our physical makeup.
 One potential implication of this is that one may--after first confronting the tax evader and imploring him to pay his allotted taxes--report him to government authorities, just as you would report one who broke into your house. While we tend to downplay white-collar crime, there is little conceptual difference between a tax-evader and a bank robber.